Hi @makamo661, how would you expect grandTotal to update? Its calculated value doesn’t appear to depend on the items in any way, so it probably just stays the same… you might check if the getter actually gets called though by inserting a console.log().
Well the getter probably does get called, it just yields the same result as before having deleted an item. Where is this.items being used to compute the result of this.grandTotal?
How is this.grandTotal supposed to update in relation to this.items? Could you provide a minimal example on stackblitz or the like that demonstrates the issue?
Sorry the above link was messed up, I’ve edited the post. Anyway here’s a minimal example to remove items from a list, which then also updates the value from a related getter:
Could you modify this example to demonstrate your problem? Please note that we do not have access to your database or anything, so some hard-coded mock data will have to do.
Okay in that code you’re not using a getter any more; grandTotal needs to be explicitly updated by calling calcGrandTotal(), which you’re only doing on init. So you might adjust your deleteItem() method like so:
I suppose if you retrieve the items ansynchronously from the backend you’d have to call calcGrandTotal() after that – on init the items would just be an empty array. But if you don’t want to display it to the user anyway then on submit would of course suffice. :-)