when an ISO date format is loaded to a reactive model it shows an invalid date.
https://stackblitz.com/edit/angular-dpshux
ngx-bootstrap: 2.0.3
Angular: 5.2.8
Bootstrap: 4.0
Angular CLI 1.7.3
Datepicker model format is a Date object and you provided a string. This string has to be converted into a Date object before using it in datepicker.
It used to work with version 2.0.beta8
@IlyaSurmay I think this should be reopened, datepicker should work with iso strings. Otherwise I have to process every date in the output from an api.
agreed with the above; this means we can't just materialize from json and bind with ngModel, we have to transform it. And it means that in typescript, if I expect it to be materialized as a string, but datepicker needs it as a Date, then I have to set that field in the dto's interface to type any so that I can assign a Date to it programmatically on load, and that's just weird.
Is this really the intent/policy of this project? I notice that writeValue(value: Date | string)...
What's the rational behind making the property strict to Date type? No service will provide you a date property in the type Date so it is literally causing us to write unnecessary code to instantiate a date object with the property of the ISO date string. It should just allow to accept both (Date | string)
This should reopened. This is really weird behavior. I am using reactive forms & facing the exact same issue. Any updates on this issue?
Most helpful comment
What's the rational behind making the property strict to
Datetype? No service will provide you a date property in the typeDateso it is literally causing us to write unnecessary code to instantiate a date object with the property of the ISO date string. It should just allow to accept both(Date | string)