Displaying Length of Filtered ng-repeat Data
As you have an ng-repeat directive displaying data filtered by user input, you want the displayed count of people to reflect the filtered results.
In Angular 1.3 , you can use an alias expression to achieve this:
<div ng-repeat="person in data | filter:query as filtered"> </div>
The "filtered" alias represents the filtered array, which you can then use to display the count:
Showing {{filtered.length}} Persons
Prior to Angular 1.3, you can assign the filtered results to a new variable and access it:
<div ng-repeat="person in filtered = (data | filter: query)"> </div>
Showing {{filtered.length}} Persons
This way, the "filtered" variable will contain the filtered results, and the count will accurately display the number of filtered people.
The above is the detailed content of How to Display the Length of Filtered Data in Angular's `ng-repeat` Directive?. For more information, please follow other related articles on the PHP Chinese website!