我想添加工作項目成本,但它顯示原始值。如何在Angularjs中添加項目成本?
例子:
item[1].cost =2 ,item[2].cost = 2 ..
當我添加第三個item[3].cost = 8
這是Total = 228
。我想添加SUM,如何做到這一點?我要總共=12
。
addWorkItem() {
this.current_job.work_items.push(this.current_workitem);
this.Total = 0;
for (var i = 0, len = this.current_job.work_items.length; i < len; i++) {
this.Total += this.current_job.work_items[i].cost;
}
this.current_workitem = {};
}
很難說沒有看到更多的代碼,但看起來你應該叫parseFloat上this.current_job.work_items [I]。成本計算this.Total –
什麼時候不工作?你對Total有什麼價值? – RamblinRose