Home > Enterprise >  how to sum input values in angular
how to sum input values in angular

Time:03-23

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

CodePudding user response:

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

CodePudding user response:

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

  • Related