-
Notifications
You must be signed in to change notification settings - Fork 183
/
Copy pathlogin-reactive.component.ts
54 lines (46 loc) · 1.04 KB
/
login-reactive.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { Component, OnInit } from "@angular/core";
import {
FormBuilder,
FormControl,
FormGroup,
NonNullableFormBuilder,
Validators,
} from "@angular/forms";
import { createPasswordStrengthValidator } from "../validators/password-strength.validator";
@Component({
selector: "login",
templateUrl: "./login-reactive.component.html",
styleUrls: ["./login-reactive.component.css"],
})
export class LoginReactiveComponent implements OnInit {
form = this.fb.group({
email: [
"",
{
validators: [Validators.required, Validators.email],
updateOn: "blur",
},
],
password: [
"",
[
Validators.required,
Validators.minLength(8),
createPasswordStrengthValidator(),
],
],
});
constructor(private fb: NonNullableFormBuilder) {}
ngOnInit() {}
get email() {
return this.form.controls["email"];
}
get password() {
return this.form.controls["password"];
}
login() {}
reset() {
this.form.reset();
console.log(this.form.value);
}
}