Issue
I try the following
new FormControl<boolean | undefined>({ value: true }, Validators.required),
and get the error that no overloads
for boolean
exists. Using
new FormControl<string | null>({ value: null, disabled: false }));
works ==> So, what is the correct syntax in Angular 14 for Typed FormControls for boolean
?
Solution
You can define it like the following:
new FormControl<boolean>(true, Validators.required);
And you can pass options to it like the following:
new FormControl<boolean>(true, {
updateOn: 'submit',
nonNullable: true,
validators: Validators.required,
});
Read more about Angular 14 Typed Forms here: https://angular.io/guide/typed-forms#specifying-an-explicit-type
Answered By - Amer
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.