Reputation: 2046
I have a list called ListA
. I am performing some filters on it and saving in a new array called filteredList
.
<div ng-repeat="element in filteredList =(ListA| filter: {label:searchCategory.value} |filter:searchString)">
NOW, I want to use the filteredList
to implement pagination. I have already implemented pagination for another page using splice(start, end)
where I update the start
and end
values to update the visible array.
Adding splice to filter will change my filteredList
size, which I need in order to calculate the number of pages for pagination.
What I would need to go into ng-repeat
would be something like this
ng-repeat="element in newList.splice(start, end)" where `newList` without splice is essentially `filteredList`.
Upvotes: 0
Views: 42
Reputation: 4672
In this scenario, what you would need is to filter the List in the Javascript itself.
For your scenario
In your controller:
var ListA = [<some-data>];
$scope.filteredList = $filter('filter')(ListA, searchString );
$scope.filteredList = $filter('filter')($scope.filteredList, {label:searchCategory.value} );
You should use the Filter values on click of some event and recalculate this filteredList on the handler.
If the items are less than 200 then you can implement live filtering by implementing a watcher on the filter expressions.
Upvotes: 1