var pageSize = 5; //每页显示的数量
var currentPage = 0; //当前页数
var totalPage = 0; //总页数
var totalRecords = 0;//总记录数
/**
*分页实现方法 参数1:scope对象 2:数组里面放Map的一个集合 3:每页显示的数量 4:当前页
**/
function pagination($scope,items,pageSize,currentPage){
$scope.itemsPerPage = pageSize;
$scope.currentPage = currentPage;
$scope.totalPage = Math.ceil($scope.items.length/$scope.itemsPerPage)-1;
$scope.totalRecords = $scope.items.length;
$scope.prevPage = function() {
if ($scope.currentPage > 0) {
$scope.currentPage--;
}
}
$scope.prevPageDisabled = function() {
return $scope.currentPage === 0 ? "disabled" : "";
}
$scope.firstPage = function() {
$scope.currentPage = 0;
};
$scope.lastPage = function() {
$scope.currentPage = Math.ceil($scope.items.length/$scope.itemsPerPage)-1;
};
$scope.pageCount = function() {
return Math.ceil($scope.items.length/$scope.itemsPerPage)-1;
};
$scope.goPage = function(){
if($scope.goIndex){
$scope.currentPage = $scope.goIndex - 1;
}
}
$scope.nextPage = function() {
if ($scope.currentPage < $scope.pageCount()) {
$scope.currentPage++;
}
};
$scope.setPage = function() {
if ($scope.currentPage < $scope.pageCount()) {
$scope.currentPage++;
}
}
$scope.nextPageDisabled = function() {
return $scope.currentPage === $scope.pageCount() ? "disabled" : "";
}
}