How to do paging in AngularJS?

后端 未结 21 2186
轮回少年
轮回少年 2020-11-22 07:17

I have a dataset of about 1000 items in-memory and am attempting to create a pager for this dataset, but I\'m not sure on how to do this.

I\'m using a custom filter

21条回答
  •  [愿得一人]
    2020-11-22 07:54

    Overview : Pagination using

     - ng-repeat
     - uib-pagination
    

    View :

    Dispature Service Host Value
    {{x.dispature}} {{x.service}} {{x.host}} {{x.value}}
    Page: {{app.currentPage}} / {{numPages}}

    JS Controller :

    app.controller('AllEntryCtrl',['$scope','$http','$timeout','$rootScope', function($scope,$http,$timeout,$rootScope){
    
        var app = this;
        app.currentPage = 1;
        app.maxSize = 5;
        app.itemPerPage = 5;
        app.totalItems = 0;
    
        app.countRecords = function() {
            $http.get("countRecord")
            .success(function(data,status,headers,config){
                app.totalItems = data;
            })
            .error(function(data,status,header,config){
                console.log(data);
            });
        };
    
        app.getPagableRecords = function() {
            var param = {
                    page : app.currentPage,
                    size : app.itemPerPage  
            };
            $http.get("allRecordPagination",{params : param})
            .success(function(data,status,headers,config){
                app.metricsList = data.content;
            })
            .error(function(data,status,header,config){
                console.log(data);
            });
        };
    
        app.countRecords();
        app.getPagableRecords();
    
    }]);
    

提交回复
热议问题