Issue
I want to restrict property declaration while creating a FromGroup. I have tried this way.
- Create a type like this:
After that I have used this on FromGroup Generic type like this:
But in this case I am getting this error: Type 'number' is not assignable to type 'AbstractControl<any, any>'
Is it really possible to restrict FormGroup ?
Solution
Form type should be like this.
type FormType = {
id: FormControl<number | null>;
}
If you don't want to allow null values, then you can do this:
type FormType = {
id: FormControl<number>;
}
assetDeAllocationForm = new FormGroup<FormType>({
id: new FormControl(0, { nonNullable: true})
});
Answered By - Khumo Mogorosi
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.