Last active
October 1, 2024 10:35
-
-
Save parollon/e37ea40a613146445d9f6546b50e29ad to your computer and use it in GitHub Desktop.
show hide password fuction many
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <ion-input | |
| [type]="getPasswordStatus('password1')" | |
| > | |
| <ion-button | |
| (click)="showHidePassword('password1')" | |
| fill="clear" | |
| slot="end" | |
| aria-label="" | |
| > | |
| <ion-icon | |
| [name]="getPasswordIcon('password1')" | |
| slot="icon-only" | |
| ></ion-icon> | |
| </ion-button> | |
| </ion-input> | |
| interface IPasswordStatus { | |
| name: string; | |
| type: string; | |
| icon: string; | |
| } | |
| passwordStatus:IPasswordStatus[] = [ | |
| { | |
| name: 'password1', | |
| type: 'password', | |
| icon: 'eye-outline', | |
| }, | |
| { | |
| name: 'password2', | |
| type: 'password', | |
| icon: 'eye-outline', | |
| }, | |
| ]; | |
| getPasswordStatus(inputName: string) { | |
| const status = this.passwordStatus.find((t) => t.name === inputName); | |
| return status ? status.type : 'password'; | |
| } | |
| getPasswordIcon(inputName: string) { | |
| const status = this.passwordStatus.find((t) => t.name === inputName); | |
| return status ? status.icon : 'eye-outline'; | |
| } | |
| showHidePassword(inputName: string) { | |
| const status = this.passwordStatus.find((status) => status.name === inputName); | |
| if (status) { | |
| status.type = status.type === 'password' ? 'text' : 'password'; | |
| status.icon = status.icon === 'eye-outline' ? 'eye-off-outline' : 'eye-outline'; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment