Open In App

Angular PrimeNG Password Component

Angular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. In this article, we will know how to use the Password component in Angular PrimeNG.

Password Component: It is used to represent the strength indicator for the password fields. 



Properties:

Templates:



 

Styling:

Creating Angular application & module installation:

Project Structure: It will look like the following.

 

Example 1: This is the basic example that shows how to use the Password component. 




<h2>GeeksforGeeks</h2>
<h5>PrimeNG Password Component</h5>
<p-password [feedback]="false"></p-password>
<p-password [disabled]="true" [feedback]="false"></p-password>




import { NgModule } from "@angular/core";
import { BrowserModule } from "@angular/platform-browser";
import { FormsModule } from "@angular/forms";
import { BrowserAnimationsModule }
    from "@angular/platform-browser/animations";
  
import { AppComponent } from "./app.component";
import { PasswordModule } from "primeng/password";
  
@NgModule({
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
    PasswordModule,
    FormsModule,
  ],
  declarations: [AppComponent],
  bootstrap: [AppComponent],
})
export class AppModule {}

Output:

Example 2: In this example, we will know how to use the toggleMask property in the password component. 




<h2>GeeksforGeeks</h2>
<h5>PrimeNG password component</h5>
<p-password [toggleMask] ="true"></p-password>




import { NgModule } from "@angular/core";
import { BrowserModule } from "@angular/platform-browser";
import { FormsModule } from "@angular/forms";
import { BrowserAnimationsModule } 
    from "@angular/platform-browser/animations";
  
import { AppComponent } from "./app.component";
import { PasswordModule } from "primeng/password";
  
@NgModule({
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
    PasswordModule,
    FormsModule,
  ],
  declarations: [AppComponent],
  bootstrap: [AppComponent],
})
export class AppModule {}

Output:

Reference: https://primefaces.org/primeng/showcase/#/password


Article Tags :