md-datepicker min max error in reactive forms
See original GitHub issueBug, feature request, or proposal:
When using min/max with md-datepicker in reactive forms, it throws below error in console:
errors.ts:42 ERROR TypeError: date.getFullYear is not a function
at NativeDateAdapter.getYear (http://localhost:49547/node_modules/@angular/material/bundles/material.umd.js:4276:21)
at NativeDateAdapter.DateAdapter.compareDate (http://localhost:49547/node_modules/@angular/material/bundles/material.umd.js:4189:46)
at MdDatepickerInput._minValidator (http://localhost:49547/node_modules/@angular/material/bundles/material.umd.js:19994:36)
at eval (http://localhost:49547/node_modules/@angular/forms/bundles/forms.umd.js:474:49)
at Array.map (native)
at _executeValidators (http://localhost:49547/node_modules/@angular/forms/bundles/forms.umd.js:474:23)
at MdDatepickerInput.eval [as _validator] (http://localhost:49547/node_modules/@angular/forms/bundles/forms.umd.js:430:33)
at MdDatepickerInput.validate (http://localhost:49547/node_modules/@angular/material/bundles/material.umd.js:20160:39)
at eval (http://localhost:49547/node_modules/@angular/forms/bundles/forms.umd.js:722:52)
at eval (http://localhost:49547/node_modules/@angular/forms/bundles/forms.umd.js:474:49)
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
Angular material date-picker min and max date validation ...
Mine one is Reactive form! So I used {{ formgroup.get(field.key).errors | json }} instead! And I can handle now! Thanks! – ...
Read more >Datepicker - Angular Material
A value that violates the min property will have a matDatepickerMin error. A value that violates the max property will have a matDatepickerMax...
Read more >Angular min date today
Angular min date validator. In reactive form we can use Validators.min and Validators.max for min and max validation respectively while creating FormGroup.
Read more >date picker material angular
We can also provide validation like min, max, and required. ... gives support for Angular form integration using reactive forms and template-driven forms....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I believe to resolve the error, you must use a Date for
lastDate
tooEDIT: or empty string for no initial value
I would actually use
null
for no initial value, I’m not sure if empty string will work in the future