我在分页或多维数组分页中创建分页时遇到问题。 它没有显示分页的第二页。
我可能错了,但这似乎是出乎意料的行为。 Bootstrap中的一个错误,还是别的什么?
这是我从Bootstrap示例中分叉的一个Plunker。 http://plnkr.co/edit/4kph6VXHWKekd5ef3kdS?p=preview
JavaScript
angular.module('ui.bootstrap.demo', ['ui.bootstrap']);
angular.module('ui.bootstrap.demo').controller('PaginationDemoCtrl', function ($scope, $log) {
// Initializing Array A & B Example
$scope.itemsPerPage = $scope.smallItemsPerPage = 2;
$scope.bigCurrentPage = $scope.smallCurrentPage = 1;
$scope.maxSize = 5;
$scope.aArray = [{bArray : [{a:'a'},{b:'b'},{c:'c'}]},
{bArray : [{a:'d'},{b:'g'},{c:'f'}]},
{bArray : [{a:'w'},{b:'z'},{c:'e'}]}
]
// End A & B
}) .filter('offset', function () {
return function (input, start) {
if (input === undefined || !angular.isArray(input)) {
return null;
}
start = +start; //parse to int
return input.slice(start);
};
});
HTML
<!doctype html>
<html ng-app="ui.bootstrap.demo">
<head>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.js"></script>
<script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.12.1.js"></script>
<script src="example.js"></script>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div ng-controller="PaginationDemoCtrl">
<h4>Default</h4>
<b>Page {{bigCurrentPage}} of Array A</b>
<pagination total-items="aArray.length" items-per-page="itemsPerPage" ng-model="bigCurrentPage" max-size="maxSize" class="pagination-lg" boundary-links="true"></pagination>
<div ng-repeat="aObject in aArray | offset: itemsPerPage * (bigCurrentPage-1) | limitTo: itemsPerPage">
<pagination total-items="aObject.bArray.length" items-per-page="smallItemsPerPage" ng-model="smallCurrentPage" class="pagination-sm" maxsize="smallMaxSize" boundary-links="true"></pagination>
<b>Page {{smallCurrentPage}} of Array B{{($index + 1) + ( (bigCurrentPage - 1) * itemsPerPage)}}</b>
<p ng-repeat="bObject in aObject.bArray | orderBy:predicate:reverse | limitTo:smallItemsPerPage | offset: smallItemsPerPage * (testresults.smallCurrentPage-1)">
{{bObject}}
</p>
</div>
</div>
</body>
</html>