I have successfully implemented pagination on my page using a pagination control. Everything is working well, but I am unsure about how to manually disable the next button.
<pagination
total-items="totalItems"
items-per-page= "itemsPerPage"
ng-model="currentPage"
class="pagination-sm"
page="currentPage"
max-size= "maxSize"
ng-change="pageChanged(currentPage)">
</pagination>
In my controller-
$scope.currentPage = 1;
$scope.itemsPerPage = 5;
$scope.maxSize = 2;
$scope.numberofrows = 5;
$scope.fetchResult = function(startingId) {
if (startingId == undefined) {
$scope.StartingId = '';
} else {
$scope.StartingId = startingId;
}
Api.customerReq.queryProductbyperiod({ productId: $scope.customerProduct, productperiod: $scope.customerPeriod, startingid: $scope.StartingId, numberofrows: $scope.numberofrows }).$promise.then(function(result) {
if (result) {
if (result && result.length == 0) {
// error alert
}
$scope.customerResult = result;
if ($scope.currentPage == 1) {
$scope.NextStartingId = result[5].id;
} else {
$scope.NextStartingId = result[4].id;
}
$scope.previousStartingId = $scope.NextStartingId;
if ($scope.currentPage == 1) {
$scope.totalItems = result.length;
}
$scope.pageChanged = function(page) {
if (page > $scope.count) {
$scope.count++;
$scope.nextPage();
} else {
$scope.count = page;
$scope.prevPage();
}
};
$scope.prevPage = function() {
if ($scope.currentPage == 1) {
$scope.previousStartingId = '';
}
$scope.fetchResult($scope.previousStartingId);
if ($scope.currentpage > 1)
$scope.totalItems -= 5;
};
$scope.nextPage = function() {
if($scope.currentPage != 1){
$scope.numberofrows = 5;
}
$scope.fetchResult($scope.NextStartingId);
$scope.totalItems += 5;
};
On each page change, the next and previous pages are being called. How can I manually disable the next link in this scenario or make the datepicker work?
Each time I click the next or previous button, an API request is made as Cassandra has limited support for pagination. I query with the stored string ID to filter results from an ordered list in the Cassandra table, essentially performing server-side pagination.