Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Commit

Permalink
fix(datepicker): date formatting when using angular 1.3 fixes #2659
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveWM authored and Antoine Pairet committed Feb 20, 2015
1 parent ed5013b commit 5f9afe5
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 5f9afe5

Please sign in to comment.