Reputation: 27
I have a data array which contains objects (JSON format).
var users = {
'New':{
{Name:'One'},
{Name:'Two'}
},
'Old':{
{Name:'Three'},
{Name:'Four'}
}
And i use this construction to display data:
<div ng-repeat="(key, value) in users">
<p>{{key}}</p>
<div ng-repeat="user in value | filter: query">
</div>
</div>
How do I get the count of filtered data? Thanks in advance for your reply!
Upvotes: 3
Views: 1785
Reputation: 4212
It might help you!! Its use for prints filtered number of users.
{{(data|filter:query).length}}
Upvotes: 1
Reputation: 15725
You can do this http://jsfiddle.net/HB7LU/10720/
<div ng-repeat= "user in filteredValue = (value | filter:query)"></div>
Just use the filtered result as another scope variable, named filteredValue
, then you can get its length, within the scope of the controller
Upvotes: 1
Reputation: 304
you can use <div ng-repeat="user in value | filter: query as results">
and then get results.length
see example here: http://plnkr.co/edit/P0ORxHkVpreANErDGc3a?p=preview
Upvotes: 1
Reputation: 1189
As seen in this other question
Assign the filtered data in a variable
<div ng-repeat="user in filtered = (users | filter: query)">
</div>
And use the filtered.length
attribute to get the count
Upvotes: 0