【发布时间】:2026-01-27 12:45:01
【问题描述】:
我讨厌问这个问题,因为似乎所有分页问题都已得到解答。但是,我不遵循使分页页面缩短的原因。我相信我的示例与其他示例非常相似。
我得到了正确数量的选项卡,当前页面也在正确更改。但是,长度与分配的每页项目数限制不匹配。
这是我的控制器
viewsModule.controller('CountryCtrl', ['$scope', 'cacCountries', function($scope, cacCountries) {
$scope.loading = true;
$scope.countries = [];
$scope.currentPage = 1;
$scope.itemsPerPage = 20;
$scope.maxSize = 20;
cacCountries().then(function(countries) {
// console.log(countries);
$scope.loading = false;
$scope.countries = countries;
$scope.totalItems = countries.length;
});
}]);
我已将 itemsPerPage 设置为 20
在我的 html 中,我确保引用 itemsPerPage
<pagination
total-items="totalItems"
items-per-page= "itemsPerPage"
ng-model="currentPage"
class="pagination-sm">
</pagination>
我正在为数组中的 250 个对象返回 13 个选项卡。但是,所有 250 个对象都出现了。我预计每页 20 个。
ng-repeat 很简单
<tr ng-repeat="country in countries |filter:search ">
我会缺少什么来绑定当前页面?
【问题讨论】:
标签: angularjs pagination angular-ui-bootstrap