MikeDiam MikeDiam - 11 months ago 136
AngularJS Question

How to filter nested ng-repeat by parent id?

I have an array

lists = [{"id":"1234"},{"id":"5423"},{"id":"65342"}]

And array with contents:

contents = [{"id":"1","listId":"1234"},{"id":"2","listId":"5423"}]

How can I filter ng-repeat for "contents" inside ng-repeat for "lists" and filter "contents" by content.listID equal list.id?

ng-repeat="e in contents | filter: {listId: lists.id}"

You will have to parent id to child array and child array will be filtered for that parent id. plnk for similar example.