Leeuwtje Leeuwtje - 5 months ago 18
AngularJS Question

how to display the number of filtered rows outside table definition?

I have implemented a filter for my

ngtable
. Trying to display the number of filtered items like this:

How to display
nr
of filtered rows here? Outside the table definition?

{{filtered.length}}
result(s) matching the filter

<table ng-table="tableParams" class="table">
<tr ng-repeat="account in filtered =($data | filter:search.accountName | filter:search.id)">
<td>{{filtered.length}}</td>
<td data-title="'id'">
{{account.account.accountId.id}}
</td>
<td data-title="'name'">
{{account.account.accountName}}
</td>

</tr>
</table>


plunkr: http://plnkr.co/edit/Sx4YAO?p=preview

Answer

Just add $parent before your filtered in your ng-repeat and you should be fine. Ng-repeat has an isolated scope.

<tr ng-repeat="account in $parent.filtered =($data | filter:search.accountName | filter:search.id)">

Comments