Ensure there is no blank space between the bootstrap labels when using ng-repeat

When using ng-repeat in Angular.js to add labels, they appear without spacing. Check out this Plunker for a demonstration.

However, if I add labels manually by copying the HTML code, they are displayed with whitespace.

Is there a way to add white space between labels without extra styling, similar to how it is done in pure Bootstrap?

Answer №1

To enhance your HTML structure, consider implementing the following...

   <div class="panel-heading">
    My panel
    <span ng-repeat="tag in tags"><span class="label label-primary">{{tag}}</span> </span>
   </div>

See it in action:

Answer №2

Another option is to utilize CSS with the adjacent sibling selector

This type of selector will target only the element that directly follows another specified element.

.label + .label {
  margin-left: 8px;
}

Answer №3

The reason behind this issue is that when using ng-repeat, there is no automatic spacing added between the <label> elements. This is why Skelly's solution is effective. To ensure proper spacing, it is recommended to use &nbsp; as a non-breaking space since regular spaces may be removed.

<span ng-repeat="tag in tags">
    <span class="label label-primary">{{tag}}</span>&nbsp;
</span>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the benefit of using process.nextTick() prior to executing a mongoose query?

I've observed a considerable number of Mongo (mongoose ORM) Queries being performed inside the process.nextTick() method. Despite the fact that nextTick defers the execution until the next iteration, it puzzles me as to why these queries are implement ...

Error Not Captured: [$rootScope:infdig]

Here is a code snippet that I wrote: <tbody ng-repeat="dtataOne in dataOnes()"> <tr> <td>My Data</td> <td class="task-container ui-sortable" colspan="6" ng-model="dtataOne.MyModel" ui-sortable="sortableOption ...

Twilio - encountering difficulties processing phone number upon submission

I clicked on this link to follow the tutorial (you can find it via twilio.) and after completing all the necessary steps, I encountered an issue. Upon running localhost and entering a phone number, I did not receive any text message and the verification wi ...

Tips for storing an array of strings in a JSON file using Javascript

Is it possible to save an array of strings to a JSON file using Node.js? const alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']; example.json [ "a", "b&q ...

Incorporating a JavaScript file into Angular

I'm looking to incorporate a new feature from this library on GitHub into my Angular project, which will enhance my ChartJS graph. @ViewChild('myChart') myChart: ElementRef; myChartBis: Chart; .... .... const ctx = this.myChart.nativeEleme ...

At what point does a dynamically loaded CSS file in the head section of a webpage actually

If the answer is already out there somewhere, I would really appreciate a link because I just can't seem to find it. When loading .php pages, I either include 'header.php' directly with <?php include 'header.php'; ?> or on ...

What are the features of the vertical line with annotation plugin and category axis in Chart.js?

I am currently facing an issue with the vertical line in my chart created using chart.js. Specifically, the problem lies with the category axis where the years are labeled as [year 0, year 1, year 2, year 3..]. Here is an example of a functioning chart ...

Sending all received parameters in a single request in Grails

In my Grails application, I am using the following JavaScript function: function sendPostRequest() { var projectNameFilter = $("input[name='project-name-filter']").val(); var addressFilter = $("input[name='address-filter&apo ...

strange issue encountered while utilizing JavaScript's async/await syntax

Recently, I encountered an issue while trying to retrieve a random user from the randomuser API using code in my Vue frontend. // Here is the structure of the API response { info: { // details omitted }, results: [ {//random user data} ] } // This snippet ...

What is the target of the `__proto__` attribute in a constructor function?

I'm taking the time to dive deeper into prototypal inheritance. I know that an instance's __proto__ property points to the constructor function's prototype object, but where does the constructor function's __proto__ property point to? ...

Loop through the ng-repeat scope object in AngularJS

Is it possible to create rows of 3 using bootstrap and ng-repeat with data from a scope object without the loop repeating every three times due to ng-if? I am curious if something like <h4> {{yogurt[$index+1].name}} </h4> would work. Below is ...

Tips for incorporating the multiply times async function into mocha tests

I am attempting to utilize the async function foo multiple times in my mocha tests. Here is how I have structured it: describe('This test', () => { const foo = async () => { const wrapper = mount(Component); const button ...

The HTML and JavaScript implementation of the Game of Life is experiencing technical difficulties

I attempted to create my own version of the Game of Life using HTML canvas and JavaScript. With the aid of various online tutorials, I was able to write a piece of code that I am still confident in. However, upon launching the HTML page in the browser and ...

Unit testing component in Ionic 2 with Ionic's specific markup and elements

Within my Angular 2 component for an Ionic 2 app, I utilize Ionic's markup as shown below: <ion-card> <h3>{{ rawcontent.name }}</h3> <p *ngIf="rawcontent.description">{{ rawcontent.description }}</p> </ion-car ...

When using Angular 2, the array.splice() function is causing the elements to be removed from the

I am currently working with an HTML table that has default checked rows. <table> <tr> <th></th> <th>Id</th> <th>Name</th> <th>Initial</th> </tr> ...

Issue with Custom Dropdown input not triggering blur event

I've been working on a custom dropup component and have encountered some strange issues with it. The main problem is the blur event not firing when clicking outside of the input field. My goal is to hide the options elements on blur, reset the compon ...

What is the best way to adjust the padding during a scaling transformation?

Currently, I am working on a scaling transform where the origin is centered horizontally. However, I have noticed that when I scale the element, the vertical padding appears to be scaled, but the horizontal padding remains unchanged. How can I ensure that ...

Send information to a function until the array reaches its maximum length

I am facing a challenge where I have a function that accepts multiple arrays as arguments, but the data available to me is already within an array called mainArr. This mainArr consists of several array items that need to be passed as arguments to the funct ...

What are the best ways to incorporate a theme into your ReactJS project?

Looking to create a context for applying dark or light themes in repositories without the need for any manual theme change buttons. The goal is to simply set the theme and leave it as is. Currently, I have a context setup like this: import { createContext ...

Incorporating modules with angular-meteor

Struggling with integrating npm/bower modules into my web app developed with angular-meteor (Angular1) and webpack. Despite following official documentation, I keep encountering errors like: Error: [$injector:nomod] Module xxx is not available! You either ...