-
Notifications
You must be signed in to change notification settings - Fork 6.7k
datepicker validation fails on initial model value #4728
Comments
Apologies, wrong post before. See below. @kaoh, please do not use the issues forum for support related requests. Rather, please follow the instructions here. The issues forum is reserved for bugs. If you think you've found a bug, please follow these instructions. Unfortunately, if you think you have found a bug and do not follow the above instructions within a reasonable amount of time, we will close the issue due to lack of activity. |
I actually had no support request, I wanted to file a bug, so it seems to be the right place here. I'm not sure if I have the time to create a demo for the bug. Do you some test cases where the datepicker is tested? In this case it would be easy for me to initialize it with the problematic data and verify my findings or not. Has changing
to
any effect? This would already solve the problem. |
@kaoh, the reason we ask for a working plunker is that we need to see what exactly it is that you are doing and determine whether or not it is a bug or user error. Sometimes we can glean this from what users have entered in their issue and sometimes not. If you look at the source code for our repo, you will find test files for each component, but before you go down that road, I would encourage you to create a plunker that demonstrates the problem so you're not spinning your wheels unnecessarily. Reading your initial issue again, it sounds like you're trying to set the model as a string rather than a |
OK, thanks. This could be the reason. Is there a way to change this behavior, that also a string can be accepted? What I get from the back end is a JSON string, analyzing each object, what field is a date seems to be a manual task, which is cumbersome and can be improved, I have several dozen of date fields. I recently updated angular-ui and I did not had this behavior before AFAIK. |
@kaoh, that actually used to be the original behavior but we had to change due to numerous cross-browser issues. The two suggestions I've been making to people are:
The right/best solution depends on your app however. |
Thanks a lot. This should help to get my application running again. Do you think that my fix using a directive and switching |
What's the status of changing the line to
This works and removes the painful behavior. |
I initialize a
datepicker
in an input field:The initial model value is
2015-09-24T12:00:00+02:00
as a string coming from a backend REST JSON object.datepicker
is running this function later:value
is initialized with the model value anddateParser.parse(...
fails later because it is expecting adateFormat == dd-MMMM-yyyy
which is not the case.The fix for this is just to switch the first line of this function:
My fix is to include this directive and overwrite the
date
validator:The text was updated successfully, but these errors were encountered: