简体   繁体   中英

Lazy load data in ngTable

I am working with ngTable in angular-1. I am fetching huge set of date with lumen API and its take too much time. So I will do it lazy API. and API working perfectly in postman,

But how implement in ngTable in angular-1. I am new with ngTable.

$scope.tableParams2 = new NgTableParams({
    page: 1, // show first page
    count: response.data.data.per_page, // count per page       
    }, 
    {
        total: response.data.data.total,// length of data
        dataset: $scope.listCandidatesActives
    }
);

To get started with angularjs ngTable, please visit http://esvit.github.io/ng-table/#/intro/demo-real-world

and the basic configuration will be

this.tableParams1 = new ngTableParams({
      page: 1, // show first page
      count: 10, // count per page
      sorting: {
        sentDate: 'desc'    //  initial sorting
      }
    }, {
      filterDelay: 300,
      getData: function(params) {
        // ajax request to api
        return Api.get(params.url()).$promise.then(function(data) {
          params.total(data.inlineCount);
          return data.results;
        });
      }
    });

Example of this can also be found in the tutorials

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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