1
- import { AfterViewInit , ChangeDetectionStrategy , Component , OnInit , ViewChild , ViewEncapsulation } from '@angular/core' ;
1
+ import { ChangeDetectionStrategy , Component , OnInit , ViewChild , ViewEncapsulation } from '@angular/core' ;
2
2
import { Title } from '@angular/platform-browser' ;
3
3
import { MatPasswordStrengthComponent } from '@angular-material-extensions/password-strength' ;
4
- import { FormControl , FormGroup } from '@angular/forms' ;
4
+ import { FormControl } from '@angular/forms' ;
5
5
6
6
@Component ( {
7
7
selector : 'app-home' ,
@@ -10,12 +10,11 @@ import {FormControl, FormGroup} from '@angular/forms';
10
10
encapsulation : ViewEncapsulation . None ,
11
11
changeDetection : ChangeDetectionStrategy . OnPush
12
12
} )
13
- export class HomeComponent implements OnInit , AfterViewInit {
13
+ export class HomeComponent implements OnInit {
14
14
15
15
@ViewChild ( 'passwordComponentWithValidation' )
16
16
passwordComponentWithValidation2 : MatPasswordStrengthComponent ;
17
17
18
- formGroup : FormGroup ;
19
18
passwordFormControl : FormControl ;
20
19
x : FormControl ;
21
20
@@ -37,11 +36,6 @@ export class HomeComponent implements OnInit, AfterViewInit {
37
36
console . log ( 'home on init' ) ;
38
37
this . titleService . setTitle ( 'Home | mat-password-strength' ) ;
39
38
40
- this . formGroup = new FormGroup ( {
41
- 'password' : this . passwordComponentWithValidation2 . passwordFormControl ,
42
- 'confirmPass' : this . passwordComponentWithValidation2 . passwordConfirmationFormControl ,
43
- } , this . passwordComponentWithValidation2 . checkPasswords ) ;
44
-
45
39
this . passwordComponentWithValidation2 . passwordFormControl . valueChanges . subscribe ( ( ) => {
46
40
console . log ( 'passwordFormControl form control = ' , this . passwordComponentWithValidation2 . passwordFormControl ) ;
47
41
} ) ;
@@ -56,23 +50,5 @@ export class HomeComponent implements OnInit, AfterViewInit {
56
50
// console.log('password strength = ', strength);
57
51
}
58
52
59
- ngAfterViewInit ( ) : void {
60
- // console.log('pass comp on ngAfterViewInit', this.passwordComponentWithValidation2);
61
- }
62
-
63
- // validate(): ValidatorFn {
64
- // const validator = (control: AbstractControl): { [key: string]: any } => {
65
- // // this.isUndefinedOrEmpty(control);
66
- // console.log('validate', !RegExpValidator.lowerCase.test(control.value));
67
- // // control.setErrors({test: true});
68
- // if (!RegExpValidator.lowerCase.test(control.value)) {
69
- // return {
70
- // 'lowerCase': true
71
- // };
72
- // }
73
- // return undefined;
74
- // };
75
- // return validator;
76
- // }
77
53
78
54
}
0 commit comments