Hello I try figure out how make server side pagination with angularjs an ngtable.
I have two web services:
localhost:8080/app/api/period
Method GET
return json list of entities. As parameters are passed page number, range of start period and range when it stop.
localhost:8080/app/api/period/count
Method GET
return count of periods. As parameters are passed range of start period and range when it stop.
this.tableParams = new ngTableParams({
page: 1,
count: 10
}, {
counts: [10],
total: 0,
getData: function($defer, params) {
$http.get('/app/api/period', {params: {
pageNumber:params.page() - 1,
rangeStart:rangeStart,
rangeStop:rangeStop}})
.success(function(data, status) {
params.total($http.get('/app/api/period/count', {params: {
rangeStart:rangeStart,
rangeStop:rangeStop}}));
$defer.resolve(data);
});
}
});
Table params.total
isn't updated corectly so data in table are displayed but pagination buttons aren't visible.
Could anybody explain me how to use $http.get
inside of success listener of other $http.get
in this case to get correctly setted params.total
.