I wanted to multiply the num1 to num2 and put it to the subtotal. and if I push another row it will also multiply the num1 to num2
Lastly I want to add all the subtotal and put it in total how to achieve that?
here is my stackblitz that i created
https://stackblitz.com/edit/mat-dialog-example-scrwra
>Solution :
You can do this by using angular form value changes like this:
this.Info.valueChanges.subscribe((datas: Array<any>) => {
var total = 0;
datas.forEach((data, index) => {
const sub = data.num1 * data.num2;
total = total + sub;
this.Info.controls[index]
.get('subtotal')
.patchValue(sub, { emitEvent: false });
});
this.fg.get('total').patchValue(total);
});