ui-date loses information when using dateFormat (caused due to a bug in jquery-ui)
My plunker at http://plnkr.co/edit/OM1O89Aw0wi1wDgn9ul5?p=preview demonstrates the issue. Try selecting a date NOT in the current year (i.e. if you're seeing this in 2013, try selecting a date in 2014). You'll notice that the date object in the scope -- $scope.myDate -- still has 2013 as the year.
This actually happens because of how jquery-ui responds to the dateFormat setting. However, when you're in the angular world, you'd expect the following behaviour:
- The underlying date object should always be correct and neither
dateFormat,altFormat, norui-date-formatshould affect what gets stored in it - The above mentioned settings should affect ONLY what is displayed to the user.
Please note, using ui-date-format does NOT solve this issue. Because that causes the ui-date to accept and emit strings into the ngModel. How does one continue to have a Date object in the ngModel while changing what is displayed to the user.
Is there any update on this issue? I'm seeing some issues with ui-date-format as well... not sure if related.
Hello @JaKXz, if you have a jsbin that shows your issue that might be easier to see if it is related or not.
I have to revisit how the ngModel is parsed and validated.
Here's an example with nothing but parsing and validation (without any ui-date at all) that helps to see the timing of when everything is run
http://jsbin.com/leliwu/3/edit?js,console,output
If the model starts as a string or is set to a value directly we have the following occur:
- formatting
- validation
when it changes we have
- parsing
- validation
I see now the problem of starting with a string in the ngModel and then converting to a date. If I can resolve using the parsers and validators correctly then this should be ok but I probably won't have time until later this month to revisit this.