3

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!

4 Answers 4

1

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

Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

1

It might help you!! Its use for prints filtered number of users.

{{(data|filter:query).length}}

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.