1414
1515<p align =" center " >
1616 <img alt="ngx-material-password-strength" style="text-align: center;"
17- src="assets/ngx-material-password-strength/ngx-material-password-strength_demo.gif">
17+ src="assets/ngx-material-password-strength/demo_v2.0.1_2.gif">
18+ </p >
19+
20+ <p align =" center " >
21+ <img alt="ngx-material-password-strength" style="text-align: center;"
22+ src="assets/ngx-material-password-strength/demo_v2.0.1.gif">
1823</p >
1924
2025## Demo
@@ -86,6 +91,15 @@ export class OtherModule {
8691}
8792```
8893
94+ ## API
95+
96+ | option | bind | type | default | description |
97+ | :-------------------| :--------:| :------:| :------------:| :-------------------------------------------------------------------------------------------------|
98+ | password | Input() | string | - | the password to calculate its strength
99+ | externalError | Input() | boolean | false | used to change the color of the password to warn if an external error occurs
100+ | onStrengthChanged | Output() | number | - | emits the strength of the provided password in % e.g: 20%, 40%, 60%, 80% or 100%
101+
102+
89103## Usage
90104
91105add the ` ngx-material-password-strength ` element to your template:
@@ -103,21 +117,41 @@ In the following example, we integration a material input container with `ngx-ma
103117
104118``` html
105119<div >
106- <mat-form-field floatPlaceholder =" auto" style =" width : 100% " >
107- <input matInput #password
108- [type] =" inputType"
109- required
110- placeholder =" Password" >
111- <mat-hint align =" end" aria-live =" polite" >
112- {{password.value.length}} / 25
113- </mat-hint >
114- </mat-form-field >
115- <ngx-material-password-strength
116- [password] =" password.value" >
117- </ngx-material-password-strength >
120+ <mat-form-field appearance =" outline" style =" width : 100% " [color] =" passwordComponent.color" >
121+ <mat-label >Password</mat-label >
122+ <input matInput #password
123+ [type] =" inputType"
124+ required
125+ placeholder =" Password" >
126+ <mat-hint align =" end" aria-live =" polite" >
127+ {{password.value.length}} / 25
128+ </mat-hint >
129+ </mat-form-field >
130+
131+ <ngx-material-password-strength #passwordComponent
132+ (onStrengthChanged) =" onStrengthChanged($event)"
133+ [password] =" password.value" >
134+ </ngx-material-password-strength >
118135 </div >
119136```
120137
138+ Example of how to use the emitted strength of the password in your template
139+ ``` html
140+ <div fxLayout =" row" fxLayoutGap =" 10px" >
141+ <div *ngIf =" passwordComponent.strength === 100; then done else error" >
142+ </div >
143+ <ng-template #done >
144+ <mat-icon color =" primary" >done</mat-icon >
145+ </ng-template >
146+ <ng-template #error >
147+ <mat-icon color =" warn" >error</mat-icon >
148+ </ng-template >
149+ <div >
150+ <p >Password's strength = {{passwordComponent.strength}} %100</p >
151+ </div >
152+ </div >
153+ ``
154+
121155[learn more about mat-form-field](https://material.angular.io/components/input/overview)
122156
123157### Please checkout the full documentation [here](https://anthonynahas.github.io/ngx-material-passowrd-strength/doc/index.html) or follow the official [tutorial](https://anthonynahas.github.io/ngx-material-password-strength/getting-started)
0 commit comments