rnadler / ng9-password-strength-bar

Angular 9+ Password Strength Bar
MIT License
0 stars 3 forks source link

ng9-password-strength-bar

Build Status npm version

This an Angular 9+ implementation of ng2-password-strength-bar.

Try it live!

Install in your project

npm install ng9-password-strength-bar --save

Run the example application locally

Run the tests locally

Using the Component

Add Component to Module imports

import { Ng9PasswordStrengthBarModule } from 'ng9-password-strength-bar';
//...
@NgModule({
 //...
   declarations: [
        AppComponent,
        //...
    ],
    imports: [
      BrowserModule,
      FormsModule,
      Ng9PasswordStrengthBarModule,
      //...
 //...
})
export class AppModule {}

Add Component to your Application

@Component({
    selector: 'my-app',
    template: `
  <h3>Angular 2 Password Strength Bar</h3>
    <div>
       <form name="myForm" novalidate>
            <input type="password" class="form-control" id="password" name="password" placeholder="Enter password"
                 [(ngModel)]="account.password" #password="ngModel"
                 minlength="5" maxlength="50" required>
            <ng9-password-strength-bar
                [passwordToCheck]="account.password"
                [barLabel]="barLabel"
                [customThresholds]="thresholds"
                [barColors]="myColors">
            </ng9-password-strength-bar>
        </form>
    </div>
  `,
})
export class App {
    public account = {
        password: <string>null
    };
    public barLabel: string = "Password strength:";
    public myColors = ['#DD2C00', '#FF6D00', '#FFD600', '#AEEA00', '#00C853'];
    public thresholds = [90, 75, 45, 25];
    // ...
}

Parameters

<ng9-password-strength-bar
  [passwordToCheck]="account.password"
  [barLabel]="barLabel"
  [barColors]="myColors"
  [baseColor]="baseColor"
  [strengthLabels]="strengthLabels"
  [customThresholds]="thresholds"
  (onStrengthChanged)="strengthChanged($event)">
</ng9-password-strength-bar>

Input Parameters

passwordToCheck (type: string)

barLabel (type: string)

barColors (type: Array\<string>, optional)

baseColor (type: string, optional)

strengthLabels (type: Array\<string>, optional)

customThresholds (type: Array\<number>, optional)

Output Parameters

onStrengthChanged(strength: number) optional

License

MIT