Form.Reset()- does not work


Topic: Form.Reset()- does not work

Torres pro asked 6 years ago

I am trying to clear inputs form. The form is inside a modal.

register.component.html

<form #registerForm="ngForm" (ngSubmit)="onSubmit(registerForm)">

register.component.ts

onSubmit(form){
//console.log(this.user);
// console.log(this._userService.pruebas());
this._userService.register(this.user).subscribe(
response => {
if(response.status == 'success'){
this.status= response.status;
//Vaciar el formulario
this.user = new User(1, 'ROLE_USER' , '', '', '', '');
form.reset()
}else{
this.status = 'error';
}
},
error => {
console.log(<any>error);
}
);

 


Damian Gemza staff commented 6 years ago

Dear Torres, Could you please specify, which version of MDB Angular you're using exactly? This problem was fixed in 6.1.6 version. Please update to the latest version of MDB Angular - 6.2.2, and try one more time. If the problem will be still present, please provide me a reproduction example, because I have tried to reproduce your problem with the basic form, and for me, everything is working fine. Best Regards, Damian

Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Open

Specification of the issue
  • User: Pro
  • Premium support: No
  • Technology: MDB Angular
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: Yes
  • Provided link: No