No spacing between bootstrap-labels with ng-repeat

When I am adding labels using ng-repeat from angular.js, they are shown without spacing. Here is a Plunker which demonstrates it.

But if I add labels manually, just has copied html, then they are shown with whitespace.

Is there a way to add white space between labels without additional styling, as it does in pure bootstrap?

Answers:

Answer

You could change your HTML markup to this...

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

Demo: http://bootply.com/113372

Answer

Or you could use CSS: Adjacent sibling selector

Adjacent selector. It will select only the specified element that immediately follows the former specified element.

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

The explanation for this is that ng-repeat does not add space between your <label> That's why the solution by Skelly works. The better way to ensure spacing is to use &nbsp; as space can be trimmed.

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

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.