Angular.js. How to count ng-repeat iterations which satisfy the custom filter

ng-repeat expression allows filtered results to be assigned to a variable. This variable will be accessible from current scope so you can use it in same scope anyway you want:

<p>Number of filtered items: {{filteredItems.length}}</p>

<div 
  ng-show="filteredItems.length > 0" 
  ng-repeat="item in filteredItems = (items | notEmpty)"
>
 {{$index}}
</div>

Leave a Comment