datepicker: Add support for passing IOS8601 strings to datepicker regardless of the DateAdapter
See original GitHub issueBug, feature request, or proposal:
Bug
What is the expected behavior?
Initial value in text field is empty string and Date picket required an input text field which means should accept empty string as not defined value, or is user want to remove value, should be able to remove text field value
What is the current behavior?
in master code in this PR : https://github.com/angular/material2/commit/8bb54ca4565a7d55d4f74ca0af4c8e7e02efb462 in this file: https://github.com/angular/material2/blob/master/src/lib/datepicker/datepicker-input.ts#L119
an empty string is not an acceptable value and it is raising the following error:
Datepicker: value not recognized as a date object by DateAdapter.
What are the steps to reproduce?
Just add
formControlName="birthdate"
to input field in datepicker and sround it by formGroup
this is plunker example: http://plnkr.co/edit/bhswcOgSB36yqD6Yr8nF?p=preview
please open chrome console to see the warning an error
What is the use-case or motivation for changing an existing behavior?
Using datepicker in form group
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
angular 4.3.2 material 2.0.0-beta.8-5967f6e
Is there anything else we should know?
It was working fine before that PR becuse the condition was
if (!value)
which is working as expected with empty string
Issue Analytics
- State:
- Created 6 years ago
- Reactions:5
- Comments:11 (5 by maintainers)
Top GitHub Comments
Allowing ISO 8601 strings by default would be extremely useful
@nicholasjativa Hmm interesting I had not considered that case. The reason I removed the ability to use strings is because it was possible to put locale-sensitive strings in your code, e.g.
1/2/2017
. Currently you would have to transform the response object to change the fields to actualDate
objects. I could maybe add back the ability to accept ISO 8601 strings only