angularUtils icon indicating copy to clipboard operation
angularUtils copied to clipboard

dirPagination: how to match the data with the pagenum by using the promise?

Open DAIGOR1024 opened this issue 8 years ago • 0 comments

Hi!Thanks for your nice lib

Here is my question I am tesing the dirPagination with AngularJS 1.5.8 and using the promise to get the server-side data every time I call the function,it will return the 10 objects and the totalnum of all data just like below:

{
    total : 59,
    data: [
        { // item 1... },
        { // item 2... },
        { // item 3... },
        ...
        { // item10... }
    ]
}

and my function in my controller like below:(call this function once,it return 10results and the totalnum at a time)

function getData(){
       var promise = Service.get($scope.term);
             promise.then(function(result) {
             $scope.totalItems = result.total
              var ii = 0
              for (; ii < result.data.length; ii++) {
                    $scope.results.push(result.data[ii]);
              }
      });
}

like the example above,total 59 objects,it will make 59/10 = 6 pagination links. but how can I match every 10 objects with each pagination link? I don't get all the data at once. how to show the correct data which have been matched with? how to set up a $watch with the code above? any ideas? Thanks a lot!

DAIGOR1024 avatar Mar 07 '17 02:03 DAIGOR1024