22 <img height =" 256px " width =" 256px " style =" text-align : center ;" src =" https://cdn.rawgit.com/anthonynahas/ngx-material-password-strength/master/demo/src/assets/logo.svg " >
33</p >
44
5- # ngx-material-password-strength - Material password strength meter to indicate how secure is the provided password
5+ # ngx-material-password-strength - Material password strength meter to indicate how secure is the provided password - Angular v6 supported
66
77[ ![ npm version] ( https://badge.fury.io/js/ngx-material-password-strength.svg )] ( https://badge.fury.io/js/ngx-material-password-strength ) ,
88[ ![ npm] ( https://img.shields.io/badge/demo-online-ed1c46.svg )] ( https://anthonynahas.github.io/ngx-material-password-strength )
2222 src="assets/ngx-material-password-strength/demo_v2.0.1.gif">
2323</p >
2424
25+ ## Table of Contents
26+ - [ Demo] ( #demo )
27+ - [ Library's components] ( #components )
28+ - [ Requirements] ( #requirements )
29+ - [ Dependencies] ( #dependencies )
30+ - [ Installation] ( #installation )
31+ - [ API] ( #api )
32+ - [ Documentation] ( #documentation )
33+ - [ Usage] ( #usage )
34+ - [ Run Demo App Locally] ( #run-demo-app-locally )
35+ - [ Development] ( #development )
36+ - [ Other Angular Libraries] ( #other-angular-libraries )
37+ - [ Support] ( #support )
38+ - [ License] ( #license )
39+
40+ <a name =" demo " />
41+
2542## Demo
2643
2744View all the directives in action at https://anthonynahas.github.io/ngx-material-password-strength
2845
29- ## Dependencies
30- * [ Angular] ( https://angular.io ) (* requires* Angular 2 or higher, tested with 2.0.0)
46+ <a name =" components " />
47+
48+ ## Library's components
49+ - ` <ngx-material-password-strength> ` used to calculate and display the strength of a provided password
50+
51+ 1 . strength score less than 20%
52+
53+ <p align =" center " >
54+ <img alt="ngx-material-password-strength score less than 20%" style="text-align: center;"
55+ src="assets/ngx-material-password-strength/v2.1.0/scrore_lesst_than_20.png">
56+ </p >
57+
58+ 2 . strength score less than 40%
59+
60+ <p align =" center " >
61+ <img alt="ngx-material-password-strength score less than 40%" style="text-align: center;"
62+ src="assets/ngx-material-password-strength/v2.1.0/scrore_lesst_than_40.png">
63+ </p >
3164
32- ### Requirements (peer dependencies):
65+ 1 . strength score less than 100%
66+
67+ <p align =" center " >
68+ <img alt="ngx-material-password-strength score less than 100%" style="text-align: center;"
69+ src="assets/ngx-material-password-strength/v2.1.0/scrore_lesst_than_100.png">
70+ </p >
71+
72+ - ` <ngx-material-password-strength-info> ` used to display more information about the strength of a provided password
73+
74+ <p align =" center " >
75+ <img alt="ngx-material-password-strength's info" style="text-align: center;"
76+ src="assets/ngx-material-password-strength/v2.1.0/ngx-material-strength-password-info.png">
77+ </p >
78+
79+ ---
80+
81+ <a name =" requirements " />
82+
83+ ## Requirements (peer dependencies):
84+ - [ angular animations ] ( https://www.npmjs.com/package/@angular/animations )
85+ - [ angular forms ] ( https://www.npmjs.com/package/@angular/forms )
86+ - [ angular cdk ] ( https://www.npmjs.com/package/@angular/cdk )
3387- [ angular material ] ( https://www.npmjs.com/package/@angular/material )
3488- [ angular material theme] ( https://material.angular.io/guide/getting-started#step-4-include-a-theme )
35- - [ angular cdk ] ( https://www.npmjs.com/package/@angular/cdk )
36- - [ angular animations ] ( https://www.npmjs.com/package/@angular/animations )
37- - if you need a built in theme --> please let me know
3889
3990``` bash
4091npm i @angular/cdk @angular/material @angular/animations
4192```
4293
94+ ---
95+
96+ <a name =" dependencies " />
97+
98+ ## Dependencies
99+ * [ Angular] ( https://angular.io ) (* requires* Angular 2 or higher, tested with 2.0.0)
100+
101+
102+ ---
103+
104+ <a name =" installation " />
43105
44106## Installation
45107Install above dependencies via * npm* .
@@ -91,14 +153,28 @@ export class OtherModule {
91153}
92154```
93155
156+ <a name =" api " />
157+
94158## API
95159
160+ ### ` <ngx-material-password-strength> ` used to calculate and display the strength of a provided password
161+
96162| option | bind | type | default | description |
97163| :-------------------| :--------:| :------:| :------------:| :-------------------------------------------------------------------------------------------------|
98164| password | Input() | string | - | the password to calculate its strength
99165| externalError | Input() | boolean | false | used to change the color of the password to warn if an external error occurs
100166| onStrengthChanged | Output() | number | - | emits the strength of the provided password in % e.g: 20%, 40%, 60%, 80% or 100%
101167
168+ ### ` <ngx-material-password-strength-info> ` used to display more information about the strength of a provided password
169+
170+ | option | bind | type | default | description |
171+ | :-------------------| :--------:| :------:| :------------:| :-------------------------------------------------------------------------------------------------|
172+ | passwordComponent | Input() | PasswordStrengthComponent | - | the password component used in the template in order to display more info related to the provided password
173+
174+
175+ <a name =" documentation " />
176+
177+ ## [ Documentation] ( https://anthonynahas.github.io/ngx-material-password-strength/doc/index.html )
102178
103179## Usage
104180
@@ -110,10 +186,10 @@ add the `ngx-material-password-strength` element to your template:
110186 </ngx-material-password-strength >
111187```
112188
113- This will display only the material password strength meter in form of a progress without any input conatiner
114- or else .
189+ This will display only the material password strength meter in form of a progress without any input fields
190+ or similar .
115191
116- In the following example, we integration a material input container with ` ngx-material-password-strength ` 's component.
192+ #### In the following example, we integration a material input container with ` ngx-material-password-strength ` 's component.
117193
118194``` html
119195<div >
@@ -135,7 +211,10 @@ In the following example, we integration a material input container with `ngx-ma
135211 </div >
136212```
137213
138- Example of how to use the emitted strength of the password in your template
214+ [ learn more about mat-form-field] ( https://material.angular.io/components/input/overview )
215+
216+ #### Example of how to use the emitted strength of the password in your template
217+
139218``` html
140219<div fxLayout =" row" fxLayoutGap =" 10px" >
141220 <div *ngIf =" passwordComponent.strength === 100; then done else error" >
@@ -150,12 +229,111 @@ Example of how to use the emitted strength of the password in your template
150229 <p >Password's strength = {{passwordComponent.strength}} %100</p >
151230 </div >
152231 </div >
153- ``
232+ ```
233+
234+ #### Client Side password's validation using a built in angular formController
235+
236+ 1 . add an input element to your template with an appropriate ngx-material-password-strength's component
237+ 2 . hold a reference of the ngx-material-password-strength's component by adding ` passwordComponentWithValidation ` (or whatever you want) inside the element
238+
239+ e.g:
240+
241+ ``` html
242+ <ngx-material-password-strength #passwordComponentWithValidation
243+ [password] =" passwordWithValidation.value" >
244+ ```
245+
246+ 3 . bind the form controller of the ngx-material-password-strength to the input element
247+ - you can access the form controller of ngx-material-password-strength using the chile view --> ` passwordComponentWithValidation.passwordFormControl `
248+ - bind the form controller to an input element --> ` [formControl]="passwordComponentWithValidation.passwordFormControl" `
249+
250+ 4 . Full example - see below
251+
252+ ``` html
253+ <div >
254+ <mat-form-field appearance =" outline" style =" width : 100% " >
255+ <mat-label >Password</mat-label >
256+ <input matInput #passwordWithValidation
257+ [type] =" inputType"
258+ required
259+ [formControl] =" passwordComponentWithValidation.passwordFormControl"
260+ placeholder =" Password" >
261+ <mat-hint align =" end" aria-live =" polite" >
262+ {{passwordWithValidation.value.length}} / 25
263+ </mat-hint >
264+ <mat-error *ngIf =" passwordComponentWithValidation.passwordFormControl.hasError('required')" >
265+ Password is required
266+ </mat-error >
267+ <mat-error *ngIf =" passwordComponentWithValidation.passwordFormControl.hasError('pattern')" >
268+ Password is not valid
269+ </mat-error >
270+ </mat-form-field >
271+ <ngx-material-password-strength #passwordComponentWithValidation
272+ (onStrengthChanged) =" onStrengthChanged($event)"
273+ [password] =" passwordWithValidation.value" >
274+ </ngx-material-password-
275+ <!--Password ' s strength info-->
276+ <ngx-material-password-strength-info
277+ [passwordComponent]="passwordComponentWithValidation">
278+ </ngx-material-password-stren
279+ </div>
280+ ```
154281
155- [learn more about mat-form-field](https://material.angular.io/components/input/overview)
156282
157283### 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)
158284
285+ ## Run Demo App Locally
286+
287+ - [clone this repo](https://github.com/AnthonyNahas/ngx-material-password-strength.git) by running
288+ ```bash
289+ $ git clone https://github.com/AnthonyNahas/ngx-material-password-strength.git
290+ ```
291+
292+ - link the ngx-material-password-strength package
293+ ```bash
294+ $ gulp link
295+ ```
296+
297+ use gulp locally
298+ ```bash
299+ $ npx gulp link
300+ ```
301+
302+ for some mac os users, you may use the sudo command with gulp
303+ use gulp with sudo
304+ ```bash
305+ $ sudo gulp link
306+ ```
307+ or locally
308+ ```bash
309+ $ sudo npx gulp link
310+ ```
311+
312+ - navigate to the demo app directory
313+ ```bash
314+ $ cd demo
315+ ```
316+
317+ - install the dependencies
318+ ```bash
319+ $ npm i
320+ ```
321+
322+ - run/start/serve the app
323+ ```bash
324+ $ npm run start
325+ ```
326+ or
327+ ```bash
328+ $ ng serve --open
329+ ```
330+ - the app is now hosted by `http://localhost:4200/`
331+
332+ ----
333+
334+
335+ <a name="development"/>
336+
159337## Development
160338
161339To generate all `*.js`, `*.d.ts` and `*.metadata.json` files:
@@ -170,11 +348,23 @@ To lint all `*.ts` files:
170348$ npm run lint
171349```
172350
351+ <a name="other-angular-libraries"/>
352+
173353## Other Angular Libraries
174- - [ ngx-auth-firebaseui ] ( https://github.com/AnthonyNahas/ngx-auth-firebaseui )
354+ - [ngx-material-password-strength ](https://github.com/AnthonyNahas/ngx-material-password-strength )
175355- [ngx-material-pages](https://github.com/AnthonyNahas/ngx-material-pages)
356+ - [ngx-material-contacts](https://github.com/AnthonyNahas/ngx-material-contacts)
357+ - [ngx-material-faq](https://github.com/AnthonyNahas/ngx-material-faq)
176358- [ngx-combination-generator](https://github.com/AnthonyNahas/combination-generator)
177359
360+ <a name="support"/>
361+
362+ ## Support
363+ Drop an email to: [Anthony Nahas](mailto:[email protected] ) and I will help you! 364+
365+ ---
366+
367+ <a name="license"/>
178368
179369## License
180370
0 commit comments