34 lines
745 B
TypeScript
34 lines
745 B
TypeScript
import { Component } from '@angular/core';
|
|
import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
|
|
|
|
@Component({
|
|
selector: 'app-test',
|
|
standalone: true,
|
|
imports: [ReactiveFormsModule],
|
|
templateUrl: './test.component.html',
|
|
styleUrl: './test.component.css',
|
|
})
|
|
export class TestComponent {
|
|
public loginForm!: FormGroup;
|
|
|
|
public ngOnInit(): void {
|
|
this.loginForm = this.setUpLoginForm();
|
|
|
|
console.log(this.loginForm);
|
|
}
|
|
|
|
setUpLoginForm(): FormGroup {
|
|
return new FormGroup({
|
|
username: new FormControl('Jan'),
|
|
password: new FormControl(''),
|
|
});
|
|
}
|
|
|
|
reset(): void {
|
|
this.loginForm = this.setUpLoginForm();
|
|
}
|
|
|
|
submit(): void {
|
|
console.log(this.loginForm.value);
|
|
}
|
|
}
|