diff --git a/src/datepicker/datepicker.js b/src/datepicker/datepicker.js index 05784947d0..0a296465a6 100644 --- a/src/datepicker/datepicker.js +++ b/src/datepicker/datepicker.js @@ -523,7 +523,11 @@ 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)) { @@ -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 ); };