-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Angular 1.3.0 rc0 causes datepicker to display initial date as unformatted string #2659
Comments
Yea, I'm seeing this as well. Last release I had before upgrading to 1.3 rc0 that I knew worked was Notably, this also seems to have broken Angular-UI Bootstrap typeahead, with a similar issue |
I have the same problem. Any idea how to fix this? |
Here's a fix: After line https://github.com/angular-ui/bootstrap/blob/master/src/datepicker/datepicker.js#L525 add the following formatter:
@pkozlowski-opensource Do you have any objections for this? Essentially as @byudaniel indicated, this commit. in AngularJS 1.3 rc0 sets $viewValue for dates as a string. Adding the above $formatter ensures the date is formatted using dateFilter before the default string formatter. |
Same issue here - @bcronje fix helps |
Thanks @bcronje, I've submitted a pull request with your fix. I also had to update the $render function, otherwise any changes to the date format are ignored. |
Thanks @bcronje, It's working but then I found another issue. When the format changes but not the value, if datefilter() receives an String not matching R_ISO8601_STR it doesn't change the format.
I've fix it modifying line 549 to pass the object as Date instead of String https://github.com/angular-ui/bootstrap/blob/master/src/datepicker/datepicker.js#L549 from
to
I don't know if this modification could provoke side errors. |
Fix by @vanHuntsman is working for me on Angular 1.3.0 |
Does anyone have a clue when there will be an official fix for this very annoying error? Because of stupid limitations in our corporate environment we can not easily change the source datepicker.js as suggested by vanHuntsman... The only solution right now is to roll back angular to an earlier version in our project. |
For us the error occurs when changing from 1.3.0-beta.19 to 1.3.0-rc.1 . |
I've found a workaround in this thread (it's actually an issue with AngularStrap, but it looks like the exact same issue as here). All you have to do is add a directive:
This seems to work, see this plunker. All credit goes to @meyerds. |
Works for me too...using stable release of 1.3 |
@DaveWM thanks for the fix! |
Thanks @DaveWM! You saved my day = ) Any ETA for the official fix? |
@DaveWM you're the man! Using your fix. |
@DaveWM Thanks so much! |
Thanks for this code. So, my question here is why Please have a look at this plunker for example http://plnkr.co/edit/HKALJPWWnpyU8nU8iAvX EDIT. is it because actually not $viewValue is displayed but element.value? Shouldn't these two values be the same or not necessarily? |
Hooray! )) |
For anyone still using ~0.12 with Angular 1.3, this is a drop-in fix based on @bcronje's comment .directive('datepickerPopup', ['datepickerPopupConfig', 'dateParser', 'dateFilter', function (datepickerPopupConfig, dateParser, dateFilter) {
return {
'restrict': 'A',
'require': '^ngModel',
'link': function ($scope, element, attrs, ngModel) {
var dateFormat;
//*** Temp fix for Angular 1.3 support [#2659](https://github.com/angular-ui/bootstrap/issues/2659)
attrs.$observe('datepickerPopup', function(value) {
dateFormat = value || datepickerPopupConfig.datepickerPopup;
ngModel.$render();
});
ngModel.$formatters.push(function (value) {
return ngModel.$isEmpty(value) ? value : dateFilter(value, dateFormat);
});
}
};
}]); Just create that directive on your own module and you will have a hands-off fix for Angular 1.3 support untill |
Thank you so much for this simple fix @rvanbaalen! |
You're welcome @neonexus 👍 |
@rvanbaalen Thanks! Works perfectly. |
Hi rvanbaalen, Thank you for the fix, but for some reason it's not working for me. Here is how I am using it: I am using AngularJS 1.3.14, ui.bootstrap.min.js 0.12.1 and ui.bootstrap-tps.min.js 0.12.1 versions in my HTML, I have the datepicker-popup defined as below:
I added the same code given by you as Directive. When I changed the date on form, ng-model value in ng-change function is still showing the un-formatted long date as string. Can you tell me what I am doing wrong? Thanks. |
Please ask your question on StackOverflow. We dont have official Angular 1.3 support at the moment so it can basically be anything why its not working for you. Also, reproduce your problem in a plunkr so others can test and debug it. This email was sent from my iPhone and therefore subject to typos and other inaccuracies.
|
Sure Thank you. |
@BalajiTE prepare plunker showing the problem. Recently I successfully applied code fixes to get rid of unformatted initial dates problem. In case you want to look at it here's the plunker: http://plnkr.co/edit/HKALJPWWnpyU8nU8iAvX?p=info |
just wanted to feedback that the issue of the datepicker displaying the date unformatted is occurring for angular v1.4 also and davewm's workaround fixes the issue...tks dave+meyerds |
…-ui#2659 Closes angular-ui#3293 Closes angular-ui#3279 Closes angular-ui#2440 Closes angular-ui#2932 Closes angular-ui#3074 Closes angular-ui#2943 Closes angular-ui#2733 Fixes angular-ui#3047 Fixes angular-ui#2659 Fixes angular-ui#2681
I'm having this issue on angular |
Here's my workaround using View:
Then in my controller:
Hope it helps |
I faced a related issue with date picker. |
…ctual directive is going in fng-ui-date)
…ctual directive is going in fng-ui-date)
The behavior of $viewValue has changed in this commit. Angular 1.3 rc0 sets $viewValue for dates as a string, so date formatting fails.
The text was updated successfully, but these errors were encountered: