2

I have an ng-repeat with multiple filters like below:

Active Items Found: {{totalActiveItems}} <div ng-repeat="item in items | filter:searchFilter | filter:{active:true}"> {{item.title}} </div> 

I'm trying to store the total count outside of the ng-repeat in the totalActiveItems variable.

I saw this answer: How to display length of filtered ng-repeat data

But it doesn't seem to show how to do it for multiple filters.

2 Answers 2

1

Store the data in a temporary variable in view and display the length using an expression .

Active Items length: {{totalItems.length}} <div ng-repeat="item in totalItems=(items | filter:searchFilter | filter:{active:true})"> {{item.title}} </div> 
Sign up to request clarification or add additional context in comments.

Comments

1

Aliasing the array resulting in the filter works fine even if you're using multiple filters :

Active Items Found: {{items.length}} <div ng-repeat="item in items | filter:searchFilter | filter:{active:true} as filtered"> {{item.title}} </div> Items found after filtering : {{filtered.length}} 

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.