2016-11-18 120 views
0

我採用了棱角分明的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="&laquo;" previous-text="&lsaquo;" next-text="&rsaquo;" 
        last-text="&raquo;" 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應該在函數被調用時更新。

回答

1

在你設置total-itemsbigTotalItemsMapfre

<uib-pagination total-items="bigTotalItemsMapfre" ... 

你要爲bigTotalItemsMapfre隨時隨地數組長度分頁指令?

看你的控制器代碼它應該是:

<uib-pagination total-items="paginationMapfre.totalItems" ... 
or 
<uib-pagination total-items="paginationMapfre.length" ... 
+0

哦,我想我忘了更新,X /,是啊,這做到了,非常感謝! –