auth
This commit is contained in:
@@ -1,11 +1,37 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { ReactiveFormsModule, FormBuilder, Validators, FormGroup } from '@angular/forms';
|
||||
import { RouterLink } from '@angular/router';
|
||||
// Optional: Ein Custom Validator für den Passwort-Vergleich
|
||||
import { passwordMatchValidator } from '../../../../core/validators/password-match.validator';
|
||||
|
||||
@Component({
|
||||
selector: 'app-register',
|
||||
imports: [],
|
||||
imports: [CommonModule, ReactiveFormsModule, RouterLink],
|
||||
templateUrl: './register.component.html',
|
||||
styleUrl: './register.component.css'
|
||||
})
|
||||
export class RegisterComponent {
|
||||
registerForm: FormGroup;
|
||||
|
||||
}
|
||||
constructor(private fb: FormBuilder) {
|
||||
this.registerForm = this.fb.group({
|
||||
fullName: ['', [Validators.required]],
|
||||
email: ['', [Validators.required, Validators.email]],
|
||||
password: ['', [Validators.required, Validators.minLength(8)]],
|
||||
confirmPassword: ['', [Validators.required]]
|
||||
}, {
|
||||
validators: passwordMatchValidator // Custom Validator auf Formular-Ebene
|
||||
});
|
||||
}
|
||||
|
||||
onSubmit() {
|
||||
if (this.registerForm.valid) {
|
||||
console.log('Registrierungsdaten:', this.registerForm.value);
|
||||
// z.B. this.authService.register(this.registerForm.value);
|
||||
} else {
|
||||
this.registerForm.markAllAsTouched();
|
||||
console.log('Registrierungsformular ist ungültig.');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user