I create remeber me functionality so if In local storage any value stored ,by default that value display in textbox.
now problem is that if i click on submit without any changes in textbox then i didn’t get any value from the textbox means it takes blank value but i ntext boxc already value have.
code that i used
<ion-content class="home" padding>
<form [ngFormModel]="authForm" (ngSubmit)="onSubmit(authForm.value)">
<ion-item [class.error]="!username.valid">
<ion-label floating>Username</ion-label>
<ion-input type="text" value={{userValue}} [ngFormControl]="username"></ion-input>
</ion-item>
<div *ngIf="username.hasError('required') && username.touched"
class="error-box">*Username is required!</div>
<div *ngIf="username.hasError('minlength') && username.touched"
class="error-box">*Minimum username length is 3!</div>
<ion-item [class.error]="!password.valid">
<ion-label floating>Password</ion-label>
<ion-input type="password" value = {{pwdValue}} [ngFormControl]="password" ></ion-input>
</ion-item>
<div *ngIf="password.hasError('required') && password.touched"
class="error-box">*Password is required</div>
<div *ngIf="password.hasError('minlength') && password.touched"
class="error-box">*Minimum password length is 3!</div>
<br/><br/>
<ion-item>
<ion-label>Remember Me</ion-label>
<ion-checkbox ngmodel='isChecked' checked ={{isChecked}}></ion-checkbox>
</ion-item>
<br/><br/>
<button type="submit" class="custom-button" block>Submit</button>
</form>
</ion-content>
constructor(private navController: NavController, private fb: FormBuilder,private service: WebService) {
this.authForm = fb.group({
'username': ['', Validators.compose([Validators.required, Validators.minLength(3)])],
'password': ['', Validators.compose([Validators.required, Validators.minLength(3)])]
});
this.username = this.authForm.controls['username'];
this.password = this.authForm.controls['password'];
}
here i tried to access username value
console.log(“username”,this.username.value);