import {Component, effect, input} from '@angular/core'; import {FormControl, FormGroup, ReactiveFormsModule, Validators} from "@angular/forms"; import {NzFormControlComponent, NzFormDirective, NzFormItemComponent, NzFormLabelComponent} from "ng-zorro-antd/form"; import {NzInputDirective} from "ng-zorro-antd/input"; import {NzColDirective} from "ng-zorro-antd/grid"; import {NzFlexDirective} from "ng-zorro-antd/flex"; import {GetProductDto} from "../../services/api"; @Component({ selector: 'app-stock-form', imports: [ NzFormItemComponent, NzFormLabelComponent, NzFormControlComponent, NzInputDirective, NzColDirective, NzFormDirective, ReactiveFormsModule, NzFlexDirective ], templateUrl: './stock-form.html', styleUrl: './stock-form.css', }) export class StockForm { stockForm = new FormGroup({ id: new FormControl(null), minimalQuantity: new FormControl(null, [Validators.required]) }) product= input(); constructor() { effect(() => { if (this.product()) { this.stockForm.patchValue({ id: this.product().id, minimalQuantity: this.product().minimalQuantity, }); } }); } }