Javascript 使用多维数组引导AngularJS分页
在分页或多维数组分页中创建分页时遇到问题。 它不显示子分页的第二页 我可能错了,但这似乎是意想不到的行为。 引导程序中的一个bug,还是别的什么 下面是我从一个引导示例中派生出来的Plunker JavaScriptJavascript 使用多维数组引导AngularJS分页,javascript,angularjs,twitter-bootstrap,multidimensional-array,pagination,Javascript,Angularjs,Twitter Bootstrap,Multidimensional Array,Pagination,在分页或多维数组分页中创建分页时遇到问题。 它不显示子分页的第二页 我可能错了,但这似乎是意想不到的行为。 引导程序中的一个bug,还是别的什么 下面是我从一个引导示例中派生出来的Plunker JavaScript angular.module('ui.bootstrap.demo', ['ui.bootstrap']); angular.module('ui.bootstrap.demo').controller('PaginationDemoCtrl', function (
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>
违约
数组A的第{{bigCurrentPage}}页
数组B{($index+1)+((bigCurrentPage-1)*itemsPerPage)的第{{smallCurrentPage}}页
{{bObject}}