Reputation: 89
Is there a way to repeat an object or array of items within an object already repeated? As an example if I have this set up:
items = [
{name: 'title', person: [ person1, person2, person3, etc. ]},
{name: 'title2', person: [ person1, person2, person3, etc. ]}
]
And in the html
<div ng-repeat="item in items">
<h2>{{item.name}}</h2>
<ul>
<li>{{item.person}</li>
</ul>
</div>
I'd like to loop the people in the person array. I do not want to just have the array of people in the that ONE li. Is there a way to accomplish this within an ng-repeat?
Upvotes: 1
Views: 93
Reputation: 34288
Nested ng-repeat
can do that:
<div ng-repeat="item in items">
<h2>{{item.name}}</h2>
<ul>
<li ng-repeat="person in item.person">{{person}}</li>
</ul>
</div>
Upvotes: 3