import { Component } from '@angular/core'; import { FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms'; import { Student } from '../Student'; @Component({ selector: 'app-student-form-reactive', imports: [ReactiveFormsModule], templateUrl: './student-form-reactive.html', styleUrl: './student-form-reactive.css', }) export class StudentFormReactive { form: FormGroup = null!; ngOnInit() { this.form = new FormGroup({ name: new FormControl(null), matrikelnummer: new FormControl(null, [Validators.required, Validators.pattern('\\d+')]) }); } print() { const value = this.form.value; const model = new Student(value.name, value.matrikelnummer); console.log(model); } }