@@ -49,7 +49,7 @@ export class MatPasswordStrengthComponent implements OnInit, OnChanges {
4949
5050 passwordFormControl : AbstractControl = new FormControl ( ) ;
5151
52- private _strength : number ;
52+ private _strength = 0 ;
5353
5454 private _color : string ;
5555
@@ -58,16 +58,13 @@ export class MatPasswordStrengthComponent implements OnInit, OnChanges {
5858 }
5959
6060 ngOnChanges ( changes : SimpleChanges ) : void {
61- console . log ( '!changes.password.isFirstChange()' , changes . password . isFirstChange ( ) ) ;
61+
6262 if ( ( changes . externalError && changes . externalError . firstChange ) || changes . password . isFirstChange ( ) ) {
63- console . log ( 'ngOnChanges if' ) ;
6463 return ;
6564 } else if ( changes . externalError && changes . externalError . currentValue ) {
66- console . log ( 'ngOnChanges else if' ) ;
6765 this . _color = Colors . warn ;
6866 return ;
6967 } else {
70- console . log ( 'ngOnChanges else' ) ;
7168 this . password && this . password . length > 0 ?
7269 this . calculatePasswordStrength ( ) : this . reset ( ) ;
7370 }
@@ -78,7 +75,7 @@ export class MatPasswordStrengthComponent implements OnInit, OnChanges {
7875 }
7976
8077 get color ( ) : string {
81- console . log ( 'on color requested: ' , this . strength ) ;
78+
8279 if ( this . _strength <= 20 ) {
8380 return Colors . warn ;
8481 } else if ( this . _strength <= 80 ) {
@@ -148,16 +145,14 @@ export class MatPasswordStrengthComponent implements OnInit, OnChanges {
148145 this . passwordFormControl . setValidators ( Validators . pattern ( this . criteriaMap . get ( criteria ) ) ) ;
149146 } )
150147
151- // this.passwordFormControl = new FormControl('',
152- // [...this.validators.map(criteria => Validators.pattern(this.criteriaMap.get(criteria)))]);
153148 }
154149
155150 calculatePasswordStrength ( ) {
156151 const requirements : Array < boolean > = [ ] ;
157152 const unit = 100 / this . criteriaMap . size ;
158153
159- console . log ( 'this.criteriaMap.size = ' , this . criteriaMap . size ) ;
160- console . log ( 'unit = ' , unit ) ;
154+ // console.log('this.criteriaMap.size = ', this.criteriaMap.size);
155+ // console.log('unit = ', unit);
161156
162157 requirements . push (
163158 this . enableLengthRule ? this . _containAtLeastEightChars ( ) : false ,
@@ -167,7 +162,7 @@ export class MatPasswordStrengthComponent implements OnInit, OnChanges {
167162 this . enableSpecialCharRule ? this . _containAtLeastOneSpecialChar ( ) : false ) ;
168163
169164 this . _strength = requirements . filter ( v => v ) . length * unit ;
170- console . log ( 'length = ' , this . _strength / unit ) ;
165+ // console.log('length = ', this._strength / unit);
171166 this . onStrengthChanged . emit ( this . strength ) ;
172167 }
173168
0 commit comments