'how to sum input values in angular

i create multiple product with increment decrement for quantity like shopping cart... i have multiple product list with quantity increment ..i want to sum total qty from multiple products ... how to sum this

enter image description here

this is my output: 9

how to get this in angular

sum operation only enough for me when click on button



Solution 1:[1]

You could have event emitter that create an event whenever the user click the minus or plus button of the child item component. When you emit the event you send some data, whatever it was clicked plus or minus and update the sum variable in the parent component. See https://angular.io/guide/inputs-outputs#sending-data-to-a-parent-component

Solution 2:[2]

You can do that using reactive forms. https://angular.io/guide/reactive-forms

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Davide Laureti
Solution 2 JayTailor