I am working with angular and I am new to it . I need to toggle between text and password on click of button. I followed this post but still I am unable to see password . Can someone please help.The following is my html code
<input type="tel" #x [(ngModel)]="loginuser.password" formControlName="password" name="password" id="password" placeholder="Enter your password" class="conceal-circle">
<label for="password">Enter your password</label>
</div>
<span class="btn-eye">
<a href="javascript:void(0);" (click)="x.type=x.type=='password'?'text':'password'" class="text-dark text-decoration-none">
<i class="fa fa-eye float-right"></i>
</a>
</span>
The following is my typescript code
export class LoginComponent implements OnInit {
formGroup: FormGroup;
currentUser: User;
constructor(private router: Router, private formbuilder: FormBuilder,
private authService: AuthService, private token: TokenStorage, private loginService: LoginserviceService) { }
loginuser: LoginUser = new LoginUser();//contains user name and pwd
ngOnInit() {
this.currentUser = JSON.parse(window.sessionStorage.getItem('currentUser'));
if (typeof this.currentUser !== 'undefined') {
window.sessionStorage.removeItem('currentUser');
}
if (null !== this.token.getToken()) {
this.token.signOut();
}
this.formGroup = this.formbuilder.group({
userName: new FormControl('', Validators.required),
password: new FormControl('', Validators.required)
});
}
login(){
//some api calls here
}
}
cancel(): void {
this.loginuser.userId = '';
this.loginuser.password = '';
}
}