Number of persons filtered by" /> Number of persons filtered by" /> Number of persons filtered by"/>

Using aliases with multiple filters

259 Views Asked by At

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!

1

There are 1 best solutions below

0
Anna On BEST ANSWER

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}}