1
How can I clear the fields of a form with Angular2? I need to reset the form
I’m using the final version of angular 2 in my design
1
How can I clear the fields of a form with Angular2? I need to reset the form
I’m using the final version of angular 2 in my design
1
The fields of your form are linked to a template, certain?
<input type="text" [ngModel]="cadastro.nome" name="cadastro-nome />
Place a call to a method:
<button (click)="resetForm">Redefinir</button>
And in the method code, re-define your template:
resetForm(){
this.formulario = {
nome:' '
}
}
If your form structure is in a class, you can do the following:
resetForm(){
this.formulario = new Formulario();
}
Browser other questions tagged angular
You are not signed in. Login or sign up in order to post.
Thanks!! Solved the second way, in the class structure
– emersonnw