TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Maureen Moore
NA
206
0
Grand Total Function Returns the Wrong Grand Total
Aug 13 2020 8:38 AM
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
>
Reply
Answers (
9
)
Localhost not working
Failed to execute 'setRequestHeader' on 'XMLHttpRequest': in angular