I have an app that present invoice to the users, I have everything set except the total value of listed items in the invoice, I used the following code to sum the value but instead of getting sum , I got concatenated value
this.http.post('http://myurl',data,headers)
.map(res => res.json())
.subscribe(res => {
console.log(res)
loader.dismiss()
this.items=res.server_response;
this.totalAmount = this.getTotal();
});
});
}
;
}
getTotal() {
let total = 0;
for (var i = 0; i < this.items.length; i++) {
if (this.items[i].amount) {
total += this.items[i].amount;
this.totalAmount = total;
}
}
return total;
}
the display value is 0100035004000 for what suppose to be (1000+3500+4000)