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: [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.'); } } }