I have a projectsSiteService
in the service, which is a simple query through the ID, and then the data is displayed using ngTable
. There is currently a problem, that is, $scope.display
is a click event, and it will go to the background to re-enter every time. Get the data, but the result is the same as ngtable
Click on the bug. I looked at the ngtable
source code and found that except for the first click, the subsequent data
in the source code were all 0, causing pagination and so on to not be displayed by default. The following getData
can only be called for the first time. ?It has no effect after that. I hope God can answer~
$scope.display=function(){
projectsSiteService.get({id:id},function(realdata){
var data = $scope.sites=datas.handle(realdata).sites;//就是获取数据
if(data.length>0){
$scope.tableParams = new NgTableParams({
page: 1, // show first page
count: 2 // count per page
}, {
total: data.length, // length of data
getData: function ($defer, params) {
$defer.resolve(data.slice((params.page() - 1) * params.count(), params.page() * params.count()));
console.log(1);//只有一次出现,多次点击无效
}
});
}
});
}
Solved via stackoverflow.