I have function creates formGroup and I need to calculate one of field from two others: sum = price * count. How can I do that?
public createService = (): FormGroup => {
const group = this.fb.group({
name: [''],
measure: [''],
count: [''],
price: [''],
sum: ['']
});
group.valueChanges.subscribe(res => {
// group.patchValue({...res, sum: +res.price * +res.count});
// res.sum = +res.price * +res.count;
console.log(res);
});
return group;
}