mwfkwa
Last Updated: February 25, 2016
·
20.29K
· kelion
298941b7505eec5e45bea403f71faefe

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:
Picture

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!

Say Thanks
Respond
Awesome Job

82f9d2b0 ffd5 11e7 9bd5 132a929e586d
Senior QA Engineer
·
San Francisco Bay Area
·
Full Time