From 03e95868c3533a73814950a89509449b6b00d4b3 Mon Sep 17 00:00:00 2001 From: Dave Martin Date: Tue, 23 Sep 2014 14:17:41 +0100 Subject: [PATCH] fix(datepicker): date formatting when using angular 1.3 fixes #2659 Closes #3293 Closes #3279 Closes #2440 Closes #2932 Closes #3074 Closes #2943 Closes #2733 Fixes #3047 Fixes #2659 Fixes #2681 --- 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..bc2354f110 100644 --- a/src/datepicker/datepicker.js +++ b/src/datepicker/datepicker.js @@ -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)) { @@ -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 ); };