sqars
sqars

Reputation: 21

Reset forms in Angular2

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.

Upvotes: 2

Views: 1857

Answers (2)

Monkey D. Luffy
Monkey D. Luffy

Reputation: 190

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': ''
});

Upvotes: 0

Edmar Miyake
Edmar Miyake

Reputation: 12390

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

this.form.reset();

Upvotes: 4

Related Questions