在我的代码中,目前我每页显示2条记录,它们总共有10页显示数据,我希望它应该在标题中显示这样的总项目: 1-2 of 10意味着记录数量为10个记录中的1,2个,当我点击下一个按钮时,它应该显示另一个记录,如3-4的3-4。我没有得到任何线索如何做到这一点,角度教程没有给出任何类型,请帮助我。
这是我在html中的分页代码:
<pagination page="currentPage" max-size="maxSize" total-items="totalItems"
items-per-page="entryLimit" boundary-links="true" rotate="false" style="cursor:pointer">
</pagination>
这是我的控制器逻辑:
$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);
});
答案 0 :(得分:1)
只需在dom中进行此计算:
<ng-if="protocolModal" test-directive></test-directive>