I'm having some trouble relating to the use of ng-repeat with multiple elements. Consider the following html:
<li>
<a href="/">Link</a>
</li>
<li class="divider-vertical"></li>
I want to repeat that for every link but I can't because the ng-repeat would go on the li, and therefore miss the divider li.
Another (somewhat inconclusive) stackoverflow thread had the following directive:
app.directive('dividerVertical', function() {
return {
restrict: 'A',
link: function(scope, element, attrs) {
element.after('<li class="divider-vertical"></li>');
}
}
});
Used like this:
<li ng-repeat="link in links" divider-vertical>
<a href="{{ link.path }}">{{ link.name }}</a>
</li>
This gives me the following:
Link1 Link2 Link3 | | |
Rather than the desired:
Link1 | Link2 | Link3
I am not sure if there's something I'm doing wrong there or if the approach is fundamentally wrong.
This feels like it should be very simple to achieve and maybe I've gone off entirely on the wrong path, any pointers would be much appreciated.