allianz / ng-aquila

Angular UI Component library for the Open Insurance Platform
https://allianz.github.io/ng-aquila/
Other
205 stars 32 forks source link

Docs: More guidance for the ErrorStateMatcher + NxFormfieldErrorDirective #52

Closed JohannesHoppe closed 1 year ago

JohannesHoppe commented 1 year ago

I was a bit confused by the fact that the NxFormfieldErrorDirective controls remained invalid even after a call to fromGroup.reset().

The answer can be found here because the ErrorStateMatcher checks for form.submitted. That was unexpected for me. I suggest that you include an example like this in the docs:

How to reset a form

<form [formGroup]="myForm" (ngSubmit)="submitForm(ngForm)" #ngForm="ngForm">
submitForm(ngForm: FormGroupDirective): void {

  // won't work!
  // this.myForm.reset();

  // resets the form to the initial values and also resets the `submitted` status.
  ngForm.resetForm();
}
yd-allianz commented 1 year ago

Hi @JohannesHoppe

thanks for contributing! This is a good idea, we'll check how to update our docs.

yd-allianz commented 1 year ago

Hi @JohannesHoppe

we have included your proposal into our documentation. Thanks for contributing!