This function returns the wrong grand total. When I add items to the cart, 
it returns a much higher grand total than is actually there. How can I fix 
it?

You can see the app in action at cart-64d3f.firebaseapp.com 

In the component:

totals = [];


get grandTotal() {


let i;
let sub_total = 0;
let grand_total = 0;
if  (this.isSubmitted == true) {
 if (typeof this.product_price  !== "undefined" && typeof this.quantity  !== 
"undefined") {
                                sub_total = this.product_price * this.
quantity;
                                this.totals.push(sub_total);
                        }
                }
                          
                                
                for (i = 0; i < this.totals.length; i++) {
                        grand_total += this.totals[i];
                }
 
        return grand_total;
 
}




In the HTML:

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


-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/angular/491c8d55-3f51-45ba-abc5-c515f74413c1o%40googlegroups.com.

Reply via email to