ToggleMask in primeNg password not working

UI Components for Angular
Post Reply
igorf70
Posts: 1
Joined: 23 Jul 2021, 11:49

23 Jul 2021, 11:51

I try to use passwordModule in my code, which is working fine then I tried to add toggle mask Upsers

<input id="float-password"
type="password"
[toggleMask]="true"
pPassword />
it gives me the following error

Can't bind to 'toggleMask' since it isn't a known property of 'input'.
I have tried to find the reason and fix, but unfortunately I'm not getting it.

divyansh
Posts: 3
Joined: 04 Aug 2021, 06:31

04 Aug 2021, 06:36

toggleMask wont work with input tag. You need to import import { PasswordModule } from 'primeng/password' in app.module.ts and use like
<p-password formControlName="password" [toggleMask]="true" [feedback]="false"></p-password>

If you want to stick to input format then you can also use this workaround.

<span class="p-input-icon-right">
<i
style="cursor: pointer"
[ngClass]="
currentPassword.type == 'password'
? 'pi pi-eye'
: 'pi pi-eye-slash'
"
(click)="
currentPassword.type =
currentPassword.type == 'password' ? 'text' : 'password'
"
></i>
<input
type="password"
formControlName="currentPassword"
[feedback]="false"
pPassword
#currentPassword
/>
</span>

Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 9 guests