1

I have this code:

<tr ng-repeat="person in ctrl.persons
            | filter : { name: filterName, email: filterEmail} as filtered">

Number of persons filtered by mail and name: {{filtered.length}}

Now I add another filter:

<tr ng-repeat="person in ctrl.persons
                    | filter : { name: filterName, email: filterEmail} 
                    | limitTo : ctrl.size as filtered">

Number of persons filtered by mail and name: {{filtered.length}}

My problem is that the number of persons filtered by mail and name is wrong now, because it's limited to size. What's the best workaround to solve this?

Thanks!

Anna
  • 839
  • 2
  • 17
  • 33
  • You should use a function in order to filter your repeat. In this function, add your different filters, and apply your limitTo on it. http://stackoverflow.com/a/13216282/4781975 – Zooly May 17 '17 at 09:40

1 Answers1

0

I solved this by using brackets:

<tr ng-repeat="person in filteredPersons = (ctrl.persons
                        | filter : { name: filterName, email: filterEmail})
                        | limitTo : ctrl.size as filtered">

Number of persons filtered by mail and name: {{filteredPersons.length}}
Anna
  • 839
  • 2
  • 17
  • 33