I have several custom form control components in my Angular application, which implement ControlValueAccessor
interface and it works great.
However, whe
Another suggestion, based upon Slava's answer, is to replace the markAsDirty
, markAsPristine
, and _updatePristine
methods in the FormGroup
class:
ngOnInit(): void {
const markAsDirty = this.formGroup.markAsDirty;
this.formGroup.markAsDirty = (opts) => {
markAsDirty.apply(this.formGroup, opts);
console.log('>>>>> markAsDirty');
};
const markAsPristine = this.formGroup.markAsPristine;
this.formGroup.markAsPristine = (opts) => {
markAsPristine.apply(this.formGroup, opts);
console.log('>>>>> markAsPristine');
};
const updatePristine = this.formGroup['_updatePristine'];
this.formGroup['_updatePristine'] = (opts) => {
updatePristine.apply(this.formGroup, opts);
console.log('>>>>> updatePristine');
};
}
I'm emitting events in the console.log
locations, but other approaches would work, of course.