How to create login in ionic 2 with show/hide password

前端 未结 3 974
深忆病人
深忆病人 2021-02-04 04:54

I wanted to create a design like this using ionic 2 -> https://codepen.io/Floky87/pen/bVopyZ

Which is a login functionality that has a hide/show password.

Here\

3条回答
  •  长情又很酷
    2021-02-04 05:24

    You can do like below in your .ts file write this code

     passwordType: string = 'password';
     passwordIcon: string = 'eye-off';
    
     hideShowPassword() {
         this.passwordType = this.passwordType === 'text' ? 'password' : 'text';
         this.passwordIcon = this.passwordIcon === 'eye-off' ? 'eye' : 'eye-off';
     }
    

    in your .html write this

    
        Password
        
        
    
    

    and this will be your .scss code. Change according to your need

    .passwordIcon{
       font-size:2rem !important;
       position: relative !important;
       top: 22px !important;
       margin: 0 auto !important;
    }
    

提交回复
热议问题