How can you do server side paging with Angular's UI Bootstrap pagination directive

前端 未结 2 845
有刺的猬
有刺的猬 2021-02-01 08:01

Hi we are wanting to do server side paging with Angular\'s UI Bootstrap pagination directive. We know how to create a RESTful endpoint to serve up the pages from our servers but

2条回答
  •  独厮守ぢ
    2021-02-01 08:20

    angular.module('app', ['ui.bootstrap']);
    angular.module('app').controller('PaginationDemoCtrl', function($scope, $http) {
    
      $scope.currentPage = 1;
    
      $scope.tracks = [];
      getData();
    
    
      function getData() {
        $http.get("https://ws.spotify.com/search/1/track.json?q=kaizers+orchestra&page=" + $scope.currentPage)
          .then(function(response) {
            $scope.totalItems = response.data.info.num_results
            angular.copy(response.data.tracks, $scope.tracks)
    
    
          });
      }
    
    //get another portions of data on page changed
      $scope.pageChanged = function() {
        getData();
      };
    
    
    });
    
    
    
    
    
    
    
    
    
      

    Sample Server Pagination

    • {{track.name}}

提交回复
热议问题