简体   繁体   English

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: 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. 注意:数据库的结果总是大于10,因此应在调用函数时更新paginationMapfre.totalItems。

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" ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM