2

I am having a problem with row count in after ng-repeat and more then one filter, I want to count the current number of rows after filtering the table with more then one filter, example:

<tr ng-repeat="person in data | filter:query | filter : name | filter {m_resource: resourceFilter} | filter : {m_id : idFilter}"> </tr> 

The m_resource, m_id are filds in data, I can't use as filter due badidnet error, is there amother way to do it?

7
  • Not clear what the problem is. Can you clarify? Commented May 25, 2016 at 12:00
  • I want to count the numer of rows, after applying 3 filters. Commented May 25, 2016 at 12:00
  • is there a reference for $last? Commented May 25, 2016 at 12:03
  • 2
    Question already asked. Take a look at this answer Commented May 25, 2016 at 12:04
  • @RomainDeSaJardim I wrote this in the question, not possible for more then one filter. Commented May 25, 2016 at 12:05

3 Answers 3

2

I found something that works even if you add limitTo filter

<tr ng-repeat="person in filtered = (data | filter:query | filter : name | filter {m_resource: resourceFilter} | filter : {m_id : idFilter}) | limitTo: 5"> 

Then you have just to do

{{filtered.length}} 

Fiddle sample

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

2 Comments

Trying and posting the result.
Perfact!! Thanks!!
2

You should be able to do something like this:

ng-repeat="person in filtered = ( data | filter:query | filter : name | filter {m_resource: resourceFilter} | filter : {m_id : idFilter} )" 

And then use {{ filtered.length }} for the number of rows.

2 Comments

trying and posting the result.
Makes sense, because limitTo slices part of the list.
2
<table> <tr ng-repeat="person in rows = (data | filter:query | filter : name | filter {m_resource: resourceFilter} | filter : {m_id : idFilter})"> </tr> </table> <span>There are {{ rows.length }} rows in the table</span> 

Same question : How can I obtain the result array of an angular "| filter" expression in a variable?

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.