i have this simple code:
<form #form="ngForm" (ngSubmit)="submit(form)">
<fieldset ngModelGroup="cliente">
// inputs with ngModel
</fieldset>
<fieldset ngModelGroup="enderecos">
// inputs with ngModel
</fieldset>
<fieldset ngModelGroup="contatos">
// inputs with ngModel
</fieldset>
</form>
// My submit method
submit(form: NgForm) {
if(form.valid) {
// save
// reset method
form.reset();
}
}
When i call the method form.reset(), Angular reset all the fields by default.
My question is: Does have any chance to reset ONLY a specific ngModelGroup like "contatos" or "enderecos" and not all the form inputs?
Thanks in advise.
I think i solve done this on my method:
form.controls['contato'].reset();
'contato' is a ngModelGroup on my form.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With