My reactive form consists of more than 10 form controls and I currently have a subscription set up on the valueChanges observable to detect any changes. While this solution works well, the output always includes the entire form value object, which includes all form controls along with their values. Is there a way to specifically identify the name of the form control that was changed?
this.form = this.fb.group({
field1: ['', Validators.required],
field2: ['', Validators.required],
field3: ['', Validators.required],
field4: ['', Validators.required],
field5: ['', Validators.required],
field6: ['', Validators.required],
field7: ['', Validators.required],
field8: ['', Validators.required],
field9: ['', Validators.required],
field10: ['', Validators.required],
field11: ['', Validators.required],
field12: ['', Validators.required],
field13: [{ value: '', disabled: true }, Validators.required]
});
this.form.valueChanges.subscribe(
result => this.calculateParams(result)
);
calculateParams(result) {
console.log(result); // giving the entire form.value object
}