AngularJS分頁僅顯示一頁

[英]AngularJS pagination only shows one page


I'm using angular-ui-bootstrap-tpls version: 0.14.3 to paginate some result i bring from some database, the problem is that the pagination always looks like this:

我正在使用angular-ui-bootstrap-tpls版本:0.14.3來分配我從某些數據庫帶來的一些結果,問題是分頁總是如下所示:

 << < 1 > >>

It doesn't matter if set it up with fixed values or with dynamic values, it stays always the same. Here is my html code:

如果使用固定值或動態值進行設置無關緊要,它始終保持不變。這是我的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>

the 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
            });
        }



    }

}]);

I not sure what i'm missing/doing wrong, why it doesn't work? i was following the code from the angular site. Note: the results from the DB are always more than 10, so it should paginationMapfre.totalItems should update when the function is called.

我不確定我錯過了什么/做錯了,為什么它不起作用?我正在關注角度網站的代碼。注意:DB的結果總是超過10,所以paginationMapfre.totalItems應該在調用函數時更新。

1 个解决方案

#1


2  

In the pagination directive you're setting total-items to bigTotalItemsMapfre

在分頁指令中,您將total-items設置為bigTotalItemsMapfre

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

Are you setting bigTotalItemsMapfre to the array length anywhere?

您是否將bigTotalItemsMapfre設置為數組長度?

Looking at your controller's code it should rather be:

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

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

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2016/11/18/75e2d34ddea3c02660a574c2d4d56199.html



 
  © 2014-2022 ITdaan.com