npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ng9-password-strength-bar

v1.1.0

Published

Angular Password Strength Bar

Downloads

1,812

Readme

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

  • git clone https://github.com/rnadler/ng9-password-strength-bar.git
  • cd ng9-password-strength-bar
  • npm install
  • npm run build ng9-password-strength-bar
  • npm run start ng9-password-strength-bar-app # Open browser to http://localhost:4200

Run the tests locally

  • Same as above, except for the last step do:
  • npm run test ng9-password-strength-bar-app # Will run the tests once with the Firefox browser

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)

  • The variable containing the password to check.

barLabel (type: string)

  • The variable containing the label displayed to the left of the bar.

barColors (type: Array<string>, optional)

  • The variable can be used to define custom bar colors.
  • This must be an Array of 5 strings.
  • Lowest security level picks colors[0], ..., the highest picks colors[4].
  • If not specified, the default is: ['#F00', '#F90', '#FF0', '#9F0', '#0F0']

baseColor (type: string, optional)

  • The variable can be used to define the color of bars when no strength is applied (i.e. when there is no password text).
  • If not specified, the default is: '#DDD'. For example:
public baseColor = '#FFF';

strengthLabels (type: Array<string>, optional)

  • The variable can be used to define a strength label that will be appended to the colored bars.
  • This must be an Array of 5 strings. For example:
public strengthLabels = ['(Useless)', '(Weak)', '(Normal)', '(Strong)', '(Great!)'];

customThresholds (type: Array<number>, optional)

  • The variable can be used to define custom strength algorithm thresholds.
  • This must be an Array of 4 integers. See the source code for details on how these values are used.
  • If not specified, the default is: [90, 70, 40, 20]

Output Parameters

onStrengthChanged(strength: number) optional

  • Event triggered when the password changes.
  • Takes a single number parameter (the new password strength with value 0 to 4).
strengthChanged(strength: number) {
  this.strength = strength;
}

License

MIT