Given valueChanges listener with Angular Reactive Forms
this.companyForm.valueChanges.subscribe((value) => {
console.log('setChangesListener value', value);
});
How do I find which field was changed exactly?
There's no way to see which field changed from the top level form subscription.
However, you can individually subscribe to form controls and that way you know exactly which field changed:
Object.entries(this.formGroup.controls).forEach(value => {
const [key, control] = value;
control.valueChanges.subscribe(
(val) => {
console.log(key, val);
},
);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With