Wednesday, August 2, 2017

In Angular 4, how to a force a form to a dirty state?

If f is a FormGroup then...

this.f.dirty = true;

 
 

...will not work for setting the FormGroup's dirty flag manually. This will cause compilation errors in TypeScript as dirty is a private field. The way to do this act the right way is like so:

this.f.markAsDirty();

No comments:

Post a Comment