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.
Jefferson S. MottaPosted Jul 20, 2020, 6:55 PM
Maureen MoorePosted Jul 20, 2020, 3:12 PM
Maureen MoorePosted Jul 20, 2020, 2:46 PM
Jefferson S. MottaPosted Jul 20, 2020, 10:53 AM
Maureen MoorePosted Jul 20, 2020, 10:14 AM
Jefferson S. MottaPosted Jul 19, 2020, 6:09 PM
Maureen MoorePosted Jul 19, 2020, 5:56 PM
Maureen MoorePosted Jul 19, 2020, 2:40 PM
Maureen MoorePosted Jul 19, 2020, 12:40 PM
Maureen MoorePosted Jul 19, 2020, 9:51 AM
Maureen MoorePosted Jul 19, 2020, 8:41 AM
Maureen MoorePosted Jul 18, 2020, 3:39 PM
Jefferson S. MottaPosted Jul 17, 2020, 7:11 PM