Hi guys,
I'm trying to populate my table from inside a .then()
call of a promise returned by a separate service, e.g.:
function populateTable() {
MyService.retrieve()
.then( (response) => {
vm.myTableData = new NgTableParams({
count: 10,
page: 1
}, {
total: response.length,
getData: ($defer, params) => {
// some other stuff, further filtering etc.
params.total(response.length);
$defer.resolve(response);
}
});
})
.catch($log.log);
}
It tells me that: $defer.resolve is not a function
.
And if I console out the $defer
and params
arguments, I find that params
is undefined and $defer
is the actual value of what params
should be.
In other words, getData executes with only one argument and that's the params one.
So then I try to just use params
and synchronously return my response, i.e.:
total: response.length,
getData: (params => {
params.total(response.length);
return response;
}
And that returns my data without errors, but now the pagination doesn't work (I get the buttons, but they don't do anything and the page is just my whole data set).
So... I'm at a loss. All the documentation and examples online tell me I should use $defer
, but why would it then not be available?
Any ideas?
The problem here is that the wiki here is out of date - it's documenting an old version of ng-table.
Have a look at the examples for more up-to-date docs.
Also check the CHANGELOG.md as it details the breaking changes that have happened over the last year or so.
Oh ok. This is terribly confusing when someone is just trying to implement it for the first time and hasn't been closely watching change logs. Are the docs going to be updated soon?
I'm hoping to generate an API doc from the typescript definitions.
In the meantime, the wiki should be deleted in my opinion. That way the only place someone will look is the official examples site
Most helpful comment
I'm hoping to generate an API doc from the typescript definitions.
In the meantime, the wiki should be deleted in my opinion. That way the only place someone will look is the official examples site