Skip to content
Advertisement

Angular Date Picker is always invalid

I have an angular date picker within a reactive form with a required validator. The problem is that it is always not valid, even when a date is picked. Strangely the control does not display red when it is invalid. Do I need to do some manual css rules for this? HTML and Typescript below. A stackblitz of the issue is here https://stackblitz.com/edit/angular-ewa1kj-vv5baj?file=app/input-error-state-matcher-example.ts

I’ve tried with a without an errorStateMatcher on the date picker — same result

Thanks

Pete

HTML:

JavaScript

TypeScript:

JavaScript

Advertisement

Answer

You must add the formControlName directive to link to your formGroup:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement