import {Component, effect, input} from '@angular/core'; import {FormControl, FormGroup, FormsModule, ReactiveFormsModule, Validators} from "@angular/forms"; import {NzColDirective} from "ng-zorro-antd/grid"; import {NzFlexDirective} from "ng-zorro-antd/flex"; import {NzFormControlComponent, NzFormDirective, NzFormItemComponent, NzFormLabelComponent} from "ng-zorro-antd/form"; import {NzInputDirective} from "ng-zorro-antd/input"; import {NzOptionComponent, NzSelectComponent} from "ng-zorro-antd/select"; import {GetUserDto} from "../../services/api"; @Component({ selector: 'app-profil-form', imports: [ FormsModule, NzColDirective, NzFlexDirective, NzFormControlComponent, NzFormDirective, NzFormItemComponent, NzFormLabelComponent, NzInputDirective, ReactiveFormsModule, NzSelectComponent, NzOptionComponent ], templateUrl: './profil-form.html', styleUrl: './profil-form.css', }) export class ProfilForm { profilForm: FormGroup = new FormGroup({ name: new FormControl(null, [Validators.required]), email: new FormControl(null, [Validators.required]), fonction: new FormControl(null, [Validators.required]), password: new FormControl(null, [Validators.required]) }) user = input(); constructor() { effect(() => { if (this.user()) { this.profilForm.patchValue({ name: this.user().name, email: this.user().email, fonction: this.user().fonction, password: this.user().password }); } }); } }