I currently have infinite scroll pagination with an Elasticsearch and AngularJS search app. I am trying to change that "regular" pagination (like Google or Bing search engines). I'm trying to use AngularJS UI Bootstrap Pagination but can not seem to get it to work. It displays correctly but the click action does not work - does not load the next set of results.
Here is the HTML for the AngularJS UI Bootstrap pagination directive:
<uib-pagination class="pagination" ng-model="currentPage" ng-change="getNextPage(currentPage)" ng-click="getNextPage()" ng-if="canGetNextPage" total-items="totalItems" max-size="noOfPages" direction-links="true" items-per-page="itemsPerPage">
Here is the relevant JS code for the infinite scroll:
$scope.getNextPage = function() {
$scope.resultsPage++;
getResults();
};
and the $watchGroup:
$scope.$watchGroup(['results', 'noResults', 'isSearching', 'totalItems', 'currentPage + itemsPerPage'], function() {
var totalItems = $scope.results.documentCount;
if (!totalItems || totalItems <= $scope.results.documents.length || $scope.noResults || $scope.isSearching) {
$scope.canGetNextPage = false;
}
else {
$scope.canGetNextPage = true;
}
});
I've tried following many tutorials(here) and here as well as this SO question on this but no matter what, I can't get the click action to work. I usually put the click action code in the getNextPage function and leave the other code because the Bootstrap pagination directive is suppose to take care of that.
I was also looking into this pagination directive but not sure if that is a better solution.
I want to do client-side pagination vs server-side, I'm only loading the first 1000 json results so that should be fine.
Any help into the click action or maybe a better solution that I'm not aware of would be great!!