Relative Content

Tag Archive for angularangular-forms

How to track if Angular patchValue is already finished?

At the beginning of the application, i get server data and patch it to my form. Afterwards i would like to mark my form as pristine, so i can disable the submit button until user changes something. The problem is that patching takes so much time that i cant set my form as pristine. Only with setTimeout i can accomplish that which is a terrible solution. Any ideas how could i track if the patching is over or any alternative solution ?
Thanks !

How to use updateValueAndValidity()

I have two form controls as min and max. At the beginning min has a default value of 1 and max is empty. I want that max be always greater than min, so I defined a custom validator, which works nicely.

Typed forms, extending common controls

export interface CommonControls { selected: FormControl<boolean>; } export interface FirstFormControls extends CommonControls { name: FormControl<string>; price: FormControl<string>; } export interface SecondFormControls extends CommonControls { ordering: FormControl<number>; type: FormControl<string>; description: FormControl<string>; } export type BaseFormGroup<T extends CommonControls> = FormGroup<T>; Why can’t I extend specific controls with common controls and use them in a type? Theres an […]