AngularJS分页只显示一个页面
问题描述:
我采用了棱角分明的UI,引导,第三方物流的版本:0.14.3进行分页了一些成绩,我从一些数据库带来的问题是,分页总是看起来是这样的:AngularJS分页只显示一个页面
<< <1> >>
使用固定值或动态值设置它并不重要,它始终保持不变。 这里是我的html代码:
<uib-pagination total-items="bigTotalItemsMapfre"
ng-model="bigCurrentPageMapfre" max-size="maxSize" class="pagination-sm"
boundary-links="true" ng-change="pageChangedMapfre()" id="pagMapfre"
first-text="«" previous-text="‹" next-text="›"
last-text="»" style="margin-bottom: 5px; margin-top: 5px;"></uib-pagination>
的JavaScript:
var app=angular.module('app',['ngRoute', 'ui.bootstrap']);
app.controller("ctrl",["$http","$scope","servicio",function($http,$scope,servicio){
$scope.paginationMapfre = {
currentPage: 1,
maxSize: 5,
totalItems :50
};
$scope.init=function(){
//some petitions to the database
servicio.load(url_comentarios+"@mapfre_mx'&page="+$scope.paginationMapfre.currentPage).then(function(info){
$scope.comentariosMapfre=info.data.content; //content to paginate
$scope.paginationMapfre.totalItems = info.data.totalElements; //total elements
});
$scope.pageChangedMapfre = function(){
servicio.load(url_comentarios+"@mapfre_mx'&page="+$scope.bigCurrentPageMapfre).then(function(info){
$scope.comentariosMapfre=info.data.content; //update the content with another petition to the DB
});
}
}
}]);
我不知道我缺少/做错了,为什么它不工作?我正在关注角度网站的代码。 注意:来自数据库的结果总是超过10个,所以它应该调用MapFre.totalItems应该在函数被调用时更新。
答
在你设置total-items
到bigTotalItemsMapfre
<uib-pagination total-items="bigTotalItemsMapfre" ...
你要为bigTotalItemsMapfre
随时随地数组长度分页指令?
看你的控制器代码它应该是:
<uib-pagination total-items="paginationMapfre.totalItems" ...
or
<uib-pagination total-items="paginationMapfre.length" ...
哦,我想我忘了更新,X /,是啊,这做到了,非常感谢! –