1

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?

1
  • for that li use ng-repeat="person in item.person" Commented Nov 7, 2013 at 20:42

1 Answer 1

3

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>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.