如何做分页AngularJS
2016-01-19 · 知道合伙人数码行家
huanglenzhi
知道合伙人数码行家
向TA提问 私信TA
知道合伙人数码行家
采纳数:117538
获赞数:517198
长期从事计算机组装,维护,网络组建及管理。对计算机硬件、操作系统安装、典型网络设备具有详细认知。
向TA提问 私信TA
关注
展开全部
app.controller('BusinessCtrl', ['$scope', '$rootScope', 'BusinessService', function ($scope, $rootScope, BusinessService) {
$rootScope.title = '流水列表';
$scope.currentPage = 1;
$scope.totalPage = 1;
$scope.pageSize = 40;
$scope.pages = [];
$scope.endPage = 1;
//获取总流水
BusinessService.total().success(function (data) {
$scope.total = data;
});
$scope.load = function () {
BusinessService.list($scope.currentPage, $scope.pageSize).success(function (data) {
$scope.items = data.list;
//获取总页数
$scope.totalPage = Math.ceil(data.count / $scope.pageSize);
$scope.endPage = $scope.totalPage;
//生成数字链接
if ($scope.currentPage > 1 && $scope.currentPage < $scope.totalPage) {
$scope.pages = [
$scope.currentPage - 1,
$scope.currentPage,
$scope.currentPage + 1
];
} else if ($scope.currentPage == 1 && $scope.totalPage > 1) {
$scope.pages = [
$scope.currentPage,
$scope.currentPage + 1
];
} else if ($scope.currentPage == $scope.totalPage && $scope.totalPage > 1) {
$scope.pages = [
$scope.currentPage - 1,
$scope.currentPage
];
}
});
};
$scope.next = function () {
if ($scope.currentPage < $scope.totalPage) {
$scope.currentPage++;
$scope.load();
}
};
$scope.prev = function () {
if ($scope.currentPage > 1) {
$scope.currentPage--;
$scope.load();
}
};
$scope.loadPage = function (page) {
$scope.currentPage = page;
$scope.load();
};
}]);
$rootScope.title = '流水列表';
$scope.currentPage = 1;
$scope.totalPage = 1;
$scope.pageSize = 40;
$scope.pages = [];
$scope.endPage = 1;
//获取总流水
BusinessService.total().success(function (data) {
$scope.total = data;
});
$scope.load = function () {
BusinessService.list($scope.currentPage, $scope.pageSize).success(function (data) {
$scope.items = data.list;
//获取总页数
$scope.totalPage = Math.ceil(data.count / $scope.pageSize);
$scope.endPage = $scope.totalPage;
//生成数字链接
if ($scope.currentPage > 1 && $scope.currentPage < $scope.totalPage) {
$scope.pages = [
$scope.currentPage - 1,
$scope.currentPage,
$scope.currentPage + 1
];
} else if ($scope.currentPage == 1 && $scope.totalPage > 1) {
$scope.pages = [
$scope.currentPage,
$scope.currentPage + 1
];
} else if ($scope.currentPage == $scope.totalPage && $scope.totalPage > 1) {
$scope.pages = [
$scope.currentPage - 1,
$scope.currentPage
];
}
});
};
$scope.next = function () {
if ($scope.currentPage < $scope.totalPage) {
$scope.currentPage++;
$scope.load();
}
};
$scope.prev = function () {
if ($scope.currentPage > 1) {
$scope.currentPage--;
$scope.load();
}
};
$scope.loadPage = function (page) {
$scope.currentPage = page;
$scope.load();
};
}]);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询