On dirait que quelque chose ne va pas avec la variable freight en HTML :
Erreur dans app/freightList.component.html:13:8 Error trying to diff [objet Objet]
Voici le code
freight.service.ts
=======================
getFreight (): Promise<Freight[]> {
return this.http.get(this.freightUrl)
.toPromise()
.then(this.extractData)
.catch(this.handleError);
}
private extractData(res: Response) {
let body = res.json();
return body || { };
}
freightList.component.ts
========================
getFreight() {
this.freightService
.getFreight()
.then(freight => this.freight = freight)
.catch(error => this.error = error); // TODO: Display error message
}
freightList.component.html
============================
<tr *ngFor="let frght of freight">
<td>{{frght.grp}} - {{frght.grpname}}</td>
<td>{{frght.subgrp}} - {{frght.subgrpname}}</td>
<td>{{frght.prodno}} - {{frght.prodname}}</td>
<td>{{frght.percent}}</td>
<td>{{frght.effective_date}}</td>
<td><button (click)="deleteFreight(frght, $event)" class="btn btn-danger btn-sm"><span class="glyphicon glyphicon-remove"></span> Remove</button></td>
<td><button (click)="editFreight(frght)" class="btn btn-warning btn-sm"><span class="glyphicon glyphicon-edit"></span> Edit</button></td>
</tr>
Response body
==================
[{
"effective_date": "01/01/2016",
"grp": "01",
"grpname": "STOPS/FLEX HOSES/COVER PLATES",
"id": "1",
"percent": "10",
"prodname": "DWV PVC PIPE 100MM X 6MTR SN6 SWJ",
"prodno": "1400200",
"subgrp": "02",
"subgrpname": "DWV PIPE - UP TO 150MM"
}, {
"effective_date": "01/02/2016",
"grp": "01",
"grpname": "STOPS/FLEX HOSES/COVER PLATES",
"id": "2",
"percent": "11",
"prodname": "PVC PIPE 100MM X 6MTR SWJ SN10",
"prodno": "1400201",
"subgrp": "03",
"subgrpname": "DIMPLEX BATHROOM ACCESSORIES"
}]