in my code currently i am showing 2 records per page and their are total 10 pages showing data , i want that it should display total items like this in the header : 1-2 of 10 means record number 1,2 out of 10 record and when i click next button it should show me another record like 3-4 of 10 . i am not getting any clue how to do this , nothing of this kind is given on the angular tutorials , kindly help me out.
this is my code for pagination in html:
<pagination page="currentPage" max-size="maxSize" total-items="totalItems"
items-per-page="entryLimit" boundary-links="true" rotate="false" style="cursor:pointer">
</pagination>
here is my controller logic:
$scope.currentPage = 1;
$scope.maxSize = 2;
$scope.totalLeadItems = $scope.finalLeadData.dataval;
$scope.totalItems = $scope.finalLeadData.dataval.length;
$scope.entryLimit = 2; // items per page
$scope.noOfPages = Math.ceil($scope.totalItems / $scope.entryLimit);
$scope.search = function (item){
//console.log(item.LEAD_NM);
return !! ((angular.lowercase(item.LEAD_NM).indexOf($scope.search.LEAD || '') !== -1 || angular.lowercase(item.LEAD_MBL).indexOf($scope.search.LEAD || '') !== -1));
};
//$watch search to update pagination
$scope.$watch('search.LEAD', function (newVal) {
$scope.filtered = filterFilter($scope.finalLeadData.dataval, newVal);
$scope.totalItems = $scope.filtered.length;
$scope.noOfPages = Math.ceil($scope.totalItems / $scope.entryLimit);
$scope.currentPage = 1;
}, true);
});
Just do this calculation in the dom:
{{ currentPage * entryLimit - 1 }} - {{ currentPage * entryLimit }} of {{ totalLeadItems.length }}