I have been tinkering with no luck, at first I thought I had it but now I can't get the results of multiple filters to remain consistent.
My issue is that when I select a filter on the front-end, the first one I use works, but when I then choose a second filter on top of that, the filtered.length and number of pages resets, but the data displayed is correct. Below is what's in my controller
$scope.list= response.data;
var memberList = $scope.list;
$scope.currentPage = 1; //current page
$scope.maxSize = 5; //pagination max size
$scope.entryLimit = 25; //max rows for data table
$scope.listLength = memberList.length;
$scope.noOfPages = 22;
$scope.$watch('filterA',
function(term) {
$scope.filtered = filterFilter($scope.list, term);
$scope.noOfPages = Math.ceil($scope.filtered.length/25);
$scope.listLength = $scope.filtered.length;
}, true);
$scope.$watch('filterB',
function(term) {
$scope.filtered = filterFilter($scope.list, term);
$scope.noOfPages = Math.ceil($scope.filtered.length/25);
$scope.listLength = $scope.filtered.length;
}, true);
$scope.$watch('filterC',
function(term) {
$scope.filtered = filterFilter($scope.list, term);
$scope.noOfPages = Math.ceil($scope.filtered.length/25);
$scope.listLength = $scope.filtered.length;
}, true);
$scope.$watch('filterD',
function(term) {
$scope.filtered = filterFilter($scope.list, term);
$scope.noOfPages = Math.ceil($scope.filtered.length/25);
$scope.listLength = $scope.filtered.length;
}, true);
And then in the view, I've got 4 inputs...one is search, the others dropdown. When I use any more than one of the filters, the length does not update.
<input type="text" ng-model="filterA">
<input type="text" ng-model="filterB">
<input type="text" ng-model="filterC">
<input type="text" ng-model="filterD">
{{filtered.length}}
<uib-pagination total-items="filtered.length" items-per-page="25" next-text="Next" previous-text="Previous" ng-model="currentPage" max-size="maxSize" class="pagination-sm" boundary-link-numbers="true" boundary-links="true" num-pages="noOfPages"></uib-pagination>
<table>
<tbody>
<tr ng-repeat="post in filtered | filterA | filterB | filterC | filterD | startFrom:(currentPage-1)*entryLimit | limitTo:entryLimit">
<td>{{post.name}}</td>
</tr>
</tbody>
</table>