I use the following function in my controller:

sum = 0;
total_price = 0;


get grandTotal() {
this.total_price = this.quantity * this.product_price;
this.sum += this.total_price;
return this.sum;
}




I get quantity and product_price from the onSubmit function:

onSubmit(quantity, product_price){
this.product_price = parseFloat(product_price);
const data = {
   quantity,
   product_price
};
this.items.push(data);
localStorage.setItem('items', JSON.stringify(this.items));
}




I display grandTotal with the following:

<div> {{ grandTotal | currency:'USD':true }} </div>



I get wild values for grandTotal and I get the error:  Error: 
ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after 
it was checked.

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to angular+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/angular/3d753321-c8a5-49a0-8838-7e1152e54087o%40googlegroups.com.

Reply via email to