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
Trying to sum up the grandTotal doesn't work
Jul 17 2020 5:56 PM
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.
Reply
Answers (
13
)
Create row and columns groupings (like in SSRS) using angular Js
Button click event submits the quantity