Hi anybody please suggest me how to clear input text after logout
My typescript file
@ViewChild(“usernameInput”) cbgUsername;
@ViewChild(“passwordInput”) cbgPassword;
Thank you.
Hi anybody please suggest me how to clear input text after logout
My typescript file
@ViewChild(“usernameInput”) cbgUsername;
@ViewChild(“passwordInput”) cbgPassword;
Thank you.
Hi, here is how to clear these values:
this.cbgUsername.nativeElement.value = "";
this.cbgPassword.nativeElement.value = "";
However, as far as I know that is not the way to handle user inputs.
I would do that this way:
Template:
<ion-input [(ngModel)]="cbgUsername" type="text" autocomplete="off" autocorrect="off"></ion-input>
<ion-input [(ngModel)]="cbgPassword" type="text" autocomplete="off" autocorrect="off"></ion-input>
On .ts file:
Add two variables:
cbgUsername:string="";
cbgPassword:string="";
and to use it :
this.cbgUsername = "some name";
this.cbgUsername = "" // to clear it out.
Now the best thing is to use FormBuilder which will give you full control over the inputs and the validations.