Skip to content

Commit

Permalink
fix(datepicker): date formatting when using angular 1.3 fixes angular…
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveWM authored and Antoine Pairet committed Feb 21, 2015
1 parent ed5013b commit 23936f9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/datepicker/datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,10 @@ function ($compile, $parse, $document, $position, dateFilter, dateParser, datepi
}
ngModel.$parsers.unshift(parseDate);

ngModel.$formatters.push(function (value) {
return ngModel.$isEmpty(value) ? value : dateFilter(value, dateFormat);
});

// Inner change
scope.dateSelection = function(dt) {
if (angular.isDefined(dt)) {
Expand All @@ -544,9 +548,9 @@ function ($compile, $parse, $document, $position, dateFilter, dateParser, datepi
});
});

// Outter change
// Outer change
ngModel.$render = function() {
var date = ngModel.$viewValue ? dateFilter(ngModel.$viewValue, dateFormat) : '';
var date = ngModel.$viewValue ? dateFilter(parseDate(ngModel.$viewValue), dateFormat) : '';
element.val(date);
scope.date = parseDate( ngModel.$modelValue );
};
Expand Down

0 comments on commit 23936f9

Please sign in to comment.