Search code examples
angularjsangularjs-ng-repeatangular-filters

Angular get row count with several filters


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?


Solution

  • 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