嗨这是我的AngularJs有一次加载分页...任何人都可以告诉我如何实现延迟加载(这是我需要每次为每个页面调用服务)
//get the list and injects to the template
DWHDataExtract.list().then(function(response){
DWHDataExtract.loaded = response.data;
$scope.dwhDataExtractDetails = DWHDataExtract.loaded;
$scope.stParams.reload();
});
// parameters declared inside the scope for row count and pagination view
$scope.stParams = new ngTableParams({
page: 1, // show first page
count: 10 // count per page
},
{
counts: [10, 25, 50, 100],
total: $scope.dwhDataExtractDetails.length,
getData: function($defer, params) {
//this criteria is for search filters
var searchOptions = params.filter();
var filteredList = searchOptions ? $filter('filter')($scope.dwhDataExtractDetails, searchOptions) : $scope.dwhDataExtractDetails;
var orderedData = params.sorting() ? $filter('orderBy')(filteredList, params.orderBy()) : filteredList;
params.total(orderedData.length); // set total for recalc pagination
if(params.total() < (params.page() -1) * params.count()){
// auto reset to first page if the current page is Out Of Bounds following a recent filter
params.page(1);
}
$defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
}
});
答案 0 :(得分:0)
这可以放入控制器中,以便每次创建新控制器时都会运行。
angular.module( '应用程序') .controller('controller',[“$ scope”,function($ scope){
//在此输入你的代码。 }]);