Currently, I am in the process of developing a unique shopping cart feature where users input a number and a corresponding product is added to a display list. Users have the ability to adjust both the price and quantity of the products, with the total price automatically updating upon modification.
The challenge I am encountering involves generating two "order" divs when I enter multiple numbers (e.g., 1234 and 2345). Each div contains information on price and quantity for user customization. However, altering the price or quantity impacts the total amount for both orders instead of just the specific one being modified, creating a cross-contamination effect between the two. How can I rectify this issue within the feature?
For reproducibility purposes, here is a link to a stackbiltz showcasing the problem (Please excuse the layout imperfections as it is a minimal sample): https://stackblitz.com/edit/angular4-nsy31g
Below is the code snippet:
component:
// Relevant component code goes here
html:
<p>Essential calculations</p>
// HTML rendering code here
In essence, the main issues are:
1) Modifying the retail price or quantity should solely affect the respective order without influencing other items in the list.
2) The total amount must accurately reflect the combined sum of all orders present in the list.
Your assistance on mitigating these challenges would be greatly appreciated! Thank you!