ng-repeat without parent element
For ng-repeat
directive in angular.js we should provide element, that will be repeated. But sometimes we want to have several DOM elements for each item, without any wrapper.
In my case it was two elements for each item: left is static and right to be sortable:
For simple ng-repeat we can do it only with wrapper for each item:
<div ng-repeat="item in items">
<div>{{item.word}}</div>
<div>{{item.definition}}</div>
</div>
Since version 1.2 in angular js we have new directives — ng-repeat-start
and ng-repeat-end
and now we can replace our code to:
<div ng-repeat-start="item in items">{{item.word}}</div>
<div ng-repeat-end>{{item.definition}}</div>
Use it!
Written by Alexandr Subbotin
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Javascript
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#