Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
65
rated 0 times [  72] [ 7]  / answers: 1 / hits: 57010  / 10 Years ago, mon, december 22, 2014, 12:00:00

If I have a complex object with objects as property values, how can I filter by one of the nested properties?



Can this be done with the OOB ng-repeat filter?



Data



{
Name: 'John Smith',
Manager: {
id: 123,
Name: 'Bill Lumburg'
}
}


ngRepeat



<li ng-repeat=e in emps | filter:Manager.Name>{{ e.Name }}</li>

More From » json

 Answers
36

You need to pass in the argument to filter by:



<input ng-model=filter.key>
<ul>
<li ng-repeat=e in list | filter: {Manager: {Name: filter.key}}>
{{e.Name}} (Manager: {{e.Manager.Name}})
</li>
</ul>


Example on Plunker


[#68416] Friday, December 19, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
carrington

Total Points: 674
Total Questions: 90
Total Answers: 108

Location: Burundi
Member since Sat, Aug 21, 2021
3 Years ago
;