我有一個ngFor和發票總額是計算價格和時間 的,但我還是希望所有總如何總結所有表中字段
<tr *ngFor="let invoice of invoiceItem.rows">
<td>{{ invoice.rowName }}</td>
<td>{{ invoice.hours}}</td>
<td>{{ invoice.price }}</td>
<td>{{ invoice.comments }}</td>
<td>{{ invoice.total}} </td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td>total ex 18%</td>
<td>{{ totals }}</td>
</tr>
,並在打字稿文件總計我有構造函數應該計算總數。 多小時後,我認爲它的時間來問:(
export class DemoTestComponent {
public invoiceItem: ItemInvoice;
public invoiceItem2: ItemInvoice;
public invoices: InvoiceData;
public invoiceRows: InvoiceDetailsRows[];
public totals: number;
//public theTex: number;
//public totalsAfterTax: number;
constructor(http: Http) {
http.get('/api/Invoice/test/1').subscribe(result => {
this.invoiceItem = result.json();
this.invoiceItem.rows.forEach((item) => {
item.total = calculate(item);
})
var tempnumber;
this.invoiceItem.rows.forEach((item) => {
tempnumber += item.total;
})
this.totals = tempnumber;
//this.theTex = this.totals * 0.18;
//this.totalsAfterTax = this.totals + this.theTex;
});
}
}