Skip to content

Commit 290b13e

Browse files
committed
Fixes to work with 1.3
1 parent 8aec4f4 commit 290b13e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/date.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ angular.module('ui.date', [])
3636
showing = true;
3737
controller.$setViewValue(element.datepicker("getDate"));
3838
_onSelect(value, picker);
39-
element.blur();
39+
//element.blur();
4040
});
4141
};
4242
opts.beforeShow = function() {
@@ -56,7 +56,7 @@ angular.module('ui.date', [])
5656

5757
// Update the date picker when the model changes
5858
controller.$render = function () {
59-
var date = controller.$viewValue;
59+
var date = controller.$modelValue;
6060
if ( angular.isDefined(date) && date !== null && !angular.isDate(date) ) {
6161
throw new Error('ng-Model value must be a Date object - currently it is a ' + typeof date + ' - use ui-date-format to convert it from a string');
6262
}
@@ -88,7 +88,7 @@ angular.module('ui.date', [])
8888
var dateFormat = attrs.uiDateFormat || uiDateFormatConfig;
8989
if ( dateFormat ) {
9090
// Use the datepicker with the attribute value as the dateFormat string to convert to and from a string
91-
modelCtrl.$formatters.push(function(value) {
91+
modelCtrl.$formatters.unshift(function(value) {
9292
if (angular.isString(value) ) {
9393
return jQuery.datepicker.parseDate(dateFormat, value);
9494
}
@@ -102,9 +102,10 @@ angular.module('ui.date', [])
102102
});
103103
} else {
104104
// Default to ISO formatting
105-
modelCtrl.$formatters.push(function(value) {
105+
modelCtrl.$formatters.unshift(function(value) {
106106
if (angular.isString(value) ) {
107-
return new Date(value);
107+
var isoDate = new Date(value);
108+
return isNaN(isoDate.getTime()) ? null : isoDate;
108109
}
109110
return null;
110111
});

0 commit comments

Comments
 (0)