Reputation: 448
So say I have a JSON object 'user' with some basic properties like: 'name', 'address', 'role', etc.
I want the ng-repeat to only spit out the objects in which the property 'role' equates to 'administrator'. How would I go about doing that?
I'm thinking something like a custom filter, or possibly making a scope variable where I put the matching objects in an array, and then repeat through them.
What is the best practice for this case?
Thanks.
Upvotes: 2
Views: 5701
Reputation: 37520
The built in filter can handle this case...
<div ng-repeat="user in users | filter : {role: 'administrator'} : true">
...
</div>
Upvotes: 10