From 09fc68e222cbfc6ae42abe5ec6d9b8145e5602ff Mon Sep 17 00:00:00 2001 From: Antoine Pairet Date: Fri, 13 Feb 2015 10:21:02 +0100 Subject: [PATCH] fix(datepicker): fixes #2659 --- src/datepicker/datepicker.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/datepicker/datepicker.js b/src/datepicker/datepicker.js index 05784947d0..b7c6e66e29 100644 --- a/src/datepicker/datepicker.js +++ b/src/datepicker/datepicker.js @@ -523,6 +523,10 @@ function ($compile, $parse, $document, $position, dateFilter, dateParser, datepi } } ngModel.$parsers.unshift(parseDate); + // https://github.com/angular-ui/bootstrap/pull/2733/files + ngModel.$formatters.push(function (value) { + return ngModel.$isEmpty(value) ? value : dateFilter(value, dateFormat); + }); // Inner change scope.dateSelection = function(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 ); };