我有表格(以我的嵌入形式),我想添加分页,在这里我添加了带有分页功能的 div:
<div data-pagination="" data-num-pages="numOfPages()"
data-current-page="curPage" data-max-size="maxSize"
data-boundary-links="true"></div>
我在 javscript 中有相关代码
//pagination
$scope.curPage = 1,
$scope.itemsPerPage = 3,
$scope.maxSize = 5;
items = answer;
$scope.numOfPages = function () {
return Math.ceil(answer.length / $scope.itemsPerPage);
};
$scope.$watch('curPage + numPerPage', function() {
var begin = (($scope.curPage - 1) * $scope.itemsPerPage);
var end = begin + $scope.itemsPerPage;
console.log(begin);
console.log(end);
console.log( answer.slice(begin, end));
$scope.filteredItems = answer.slice(begin, end);
});