Reputation: 21
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
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
Reputation: 12390
In rc5, there is a reset() method in the FormGroup.
this.form.reset();
Upvotes: 4