I have an array (_users) that contains JSON objects.
{
"User":
{
"userid":"19571",
"status":"7",
"active":"1",
"lastlogin":"1339759025307",
"Stats":
[
{
"active":"1",
"catid":"10918",
"typeid":"71",
"Credits":
[
{
"content":"917,65",
"active":"1",
"type":"C7"
},
{
"content":"125,65",
"active":"1",
"type":"B2"
}
]
}
]
}
}
1- How can I filter only users with "active":"1" not "0"
I have tried something like this:
<div ng-repeat="user in _users | filter:active | orderBy:user.userid">
{{user.userid}}
</div>
but not working correctly for me.
Thank you!
Since your object model is kind of complex I would recommend using custom filtering function:
and then in your HTML:
Here is the working jsFiddle: http://jsfiddle.net/pkozlowski_opensource/4kzzy/3/
Be sure to check angular's documentation on filters if you need more info: http://docs.angularjs.org/api/ng.filter:filter
Taking @pkozlowski.opensource a bit further and allowing live filtering of items/users:
http://jsfiddle.net/hbyNN/
And: