ES6 angular-meteor ng-table getData function not called
Apparently, you just need to return the data in getData
. The old docs were using $defer.resolve
and was not returning the resolved data. The current version (1.0.0) isn't using it anymore.
this.helpers({ items() { return this.myService.getItems(); }, itemTableParams() { const data = this.getReactively('items'); return new NgTableParams({ page: 1, count: 10 }, { total: data.length, getData: (params) => { const filteredData = filterData(data); // do something return filteredData; } }); }});
The getData
method isn't being called because you fetch the data
asynchronously but use it synchronously. So when the controller is loaded initially, getData
is called with unresolved data.
To fix this, you'll need to create the NgTableParams
in the success callback of the data
object:
data.$promise.then((data) => { // create NgTableParams here});