I am not sure if I am getting this totally wrong or some minor thing is wrong with my code. But when I try Http and Promises with LocalDataSource I get this error:
vendor.bundle.js:71464 ERROR Error: Uncaught (in promise): TypeError: this.data.slice is not a function
TypeError: this.data.slice is not a function
at LocalDataSource.webpackJsonp.../../../../ng2-smart-table/lib/data-source/local/local.data-source.js.LocalDataSource.getElements (vendor.bundle.js:24597)
at LocalDataSource.webpackJsonp.../../../../ng2-smart-table/lib/data-source/data-source.js.DataSource.emitOnChanged (vendor.bundle.js:24502)
at LocalDataSource.webpackJsonp.../../../../ng2-smart-table/lib/data-source/data-source.js.DataSource.load (vendor.bundle.js:24422)
at LocalDataSource.webpackJsonp.../../../../ng2-smart-table/lib/data-source/local/local.data-source.js.LocalDataSource.load (vendor.bundle.js:24560)
at main.bundle.js:424
at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invoke (polyfills.bundle.js:5937)
at Object.onInvoke (vendor.bundle.js:74334)
at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invoke (polyfills.bundle.js:5936)
at Zone.webpackJsonp.../../../../zone.js/dist/zone.js.Zone.run (polyfills.bundle.js:5687)
But then it works with ServerDataSource. However I am not sure if I have understood the difference between these two entirely.
Here is my code in my Service:
getData(): Promise<IBatchStatus[]> { return this._http.get(this._url) .toPromise() .then(response => response.json().data as IBatchStatus[]) .catch(this.handleError); }
I am not sure if I am getting this totally wrong or some minor thing is wrong with my code. But when I try Http and Promises with LocalDataSource I get this error: vendor.bundle.js:71464 ERROR Error: Uncaught (in promise): TypeError: this.data.slice is not a function TypeError: this.data.slice is not a function
at LocalDataSource.webpackJsonp.../../../../ng2-smart-table/lib/data-source/local/local.data-source.js.LocalDataSource.getElements (vendor.bundle.js:24597) at LocalDataSource.webpackJsonp.../../../../ng2-smart-table/lib/data-source/data-source.js.DataSource.emitOnChanged (vendor.bundle.js:24502) at LocalDataSource.webpackJsonp.../../../../ng2-smart-table/lib/data-source/data-source.js.DataSource.load (vendor.bundle.js:24422) at LocalDataSource.webpackJsonp.../../../../ng2-smart-table/lib/data-source/local/local.data-source.js.LocalDataSource.load (vendor.bundle.js:24560) at main.bundle.js:424 at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invoke (polyfills.bundle.js:5937) at Object.onInvoke (vendor.bundle.js:74334) at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invoke (polyfills.bundle.js:5936) at Zone.webpackJsonp.../../../../zone.js/dist/zone.js.Zone.run (polyfills.bundle.js:5687)
But then it works with ServerDataSource. However I am not sure if I have understood the difference between these two entirely.
Here is my code in my Service:
getData(): Promise<IBatchStatus[]> { return this._http.get(this._url) .toPromise() .then(response => response.json().data as IBatchStatus[]) .catch(this.handleError); }
and my component: