Reputation: 91
How to load the local json file and display data in ng2-smart-table?
This is my current code for retrieve the data from the local json file:
public getList() {
return this.http.get('./assets/data/line-items.json')
.toPromise()
.then(response => response.json())
.then(json => {
console.log('data', json.items);
return json.items;
});
}
and I want to pass all the data to [source] in ng2-smart-table
<ng2-smart-table [settings]="settings" [source]="data"></ng2-smart-table>
Upvotes: 0
Views: 558
Reputation: 37343
getList
return a promise, so you have to do this :
this.getList().then(data=>{
this.data = data;
});
Upvotes: 1