【发布时间】:2016-11-19 07:00:55
【问题描述】:
我正在使用 angular-ui-bootstrap-tpls version: 0.14.3 对我从某个数据库带来的一些结果进行分页,问题是分页总是如下所示:
<< < 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 个,所以它应该在调用函数时更新 paginationMapfre.totalItems。
【问题讨论】:
标签: javascript angularjs angular-ui-bootstrap