Jimit H.
Jimit H.

Reputation: 195

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
    }
);

Upvotes: 0

Views: 381

Answers (1)

Sajjan Mishra
Sajjan Mishra

Reputation: 85

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

Upvotes: 0

Related Questions