2

can someone tell me how to reset form after i submit one in Angular2?

<div class="field" [ngClass]="{error: !articleForm.find('link').valid && articleForm.find('link').touched}">
    <label>Link:</label>
    <input type="text" name="link" [ngFormControl]="articleForm.controls['link']"/>
</div>

The problem is that after submit form remain '.touched'. I need to reset it. Thanks for all the help.

dfsq
  • 191,768
  • 25
  • 236
  • 258
sqars
  • 21
  • 3

2 Answers2

4

In rc5, there is a reset() method in the FormGroup.

this.form.reset();
Edmar Miyake
  • 12,047
  • 3
  • 37
  • 38
0

I am not able to understant your login in ngFormControl .

But suppose your Form Group name is submitGroup and formControlName is name then code will look like something below :

this.submitGroup.reset({
      'name': ''
});
Monkey D. Luffy
  • 181
  • 1
  • 3
  • 16