Can set some type for FormControl value?
Asked Answered
T

2

10

Framework which I use (Angular 7).

I want set some type for FormControl like this.

    startDate: FormControl<NgbDate>;
    endDate: FormControl<NgbDate>;

Do you have any experience with it or it is not posible in angular?

Tritheism answered 30/5, 2019 at 15:17 Comment(1)
You can take a look to github.com/cloudnc/ngx-sub-form we've added some type safety, not perfect but it'll at least catch that a form shape has changed when you do a refactor for example.Peanuts
L
8

For now it's not possibile. Check this issue to Angular GitHub Reactive forms are not strongly typed

Letha answered 30/5, 2019 at 15:22 Comment(1)
This is possible beginning with Angular 14, and is available now to preview in 14.0.0-next.12 or higher.Herophilus
P
1

It is available in angular 14 ,

startDate: FormControl<Date | null>(null);
endDate: FormControl<Date | null>(null);
Praxis answered 2/12, 2022 at 10:14 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Knockwurst

© 2022 - 2024 — McMap. All rights reserved.