0.0.5 • Published 4 years ago

ngx-pwd v0.0.5

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

NgxPwd

  • Password strength meter with generator all in one

Installation

npm i ngx-pwd

API

import { NgxPwdModule } from 'ngx-pwd';

@Service

import { NgxPwdService } from 'ngx-pwd';

MethodParamRequiredDescription
generatelengthDefaults: 8return random password
validatepasswordYESreturns true if password passed the rules

@Inputs()

InputTypeRequiredDescription
passwordstringYESPassword to check
validObservableOptionalreturns if password is valid
optionsobjectNONgxPwdOptions

@Output()

OutputTypeRequiredDescription
useRecPWCallbackNOEmits the generated password back to the parent component

NgxPwdOptions

OptionsTypeRequiredDescription
lengthNumberDefaults: 8Generated password length
colorStringDefaults: #18b4d7Background color of bullet when passed
hideAfterUseBooleanDefaults: falseWhether to hide generated password after used

Sample Usage

1) Register the NgxPwdModule in your app module.

import { NgxPwdModule } from 'ngx-pwd'

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';

import { AppComponent } from './app.component';
import { NgxPwdModule } from 'ngx-pwd';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    NgxPwdModule,
    FormsModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})

2) Declare the options on yout app.component.ts

import { Component } from '@angular/core';
import { BehaviorSubject } from 'rxjs';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent {
  title = 'ngx-pwd';

  valid: BehaviorSubject<any> = new BehaviorSubject(false);
  password = '';

  options = {
    length: 10,
    hideAfterUse: true
  };

  useRecPwd (pwd: string) {
    this.password = pwd;
  }
}

3) Use the component <ngx-pwd></ngx-pwd> in your component.

<div class="ngx-pwd-demo">
  <div class="ngx-pwd-demo-form">
    <p>NgxPwdModule Demo</p>

    <div class="ngx-pwd-demo-input">
      <input type="text" [(ngModel)]="password" placeholder="enter your password">
    </div>

    <div class="ngx-pwd-demo-component">
      <ngx-pwd [options]="options" [password]="password" [valid]="valid" (useRecPW)="useRecPwd($event)"></ngx-pwd>
    </div>
  </div>
</div>

Thanks to all resources

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago