简体   繁体   English

ngTable 中的延迟加载数据

[英]Lazy load data in ngTable

I am working with ngTable in angular-1.我正在使用 angular-1 中的 ngTable。 I am fetching huge set of date with lumen API and its take too much time.我正在使用流明 API 获取大量日期,这需要太多时间。 So I will do it lazy API.所以我会偷懒API。 and API working perfectly in postman,和 API 在 postman 中完美运行,

But how implement in ngTable in angular-1.但是如何在 angular-1 中的 ngTable 中实现。 I am new with ngTable.我是 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要开始使用 angularjs ngTable,请访问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这个例子也可以在教程中找到

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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