Skip to content

Commit

Permalink
fix(datepicker): fixes angular-ui#2659
Browse files Browse the repository at this point in the history
  • Loading branch information
Antoine Pairet committed Feb 13, 2015
1 parent 87b3360 commit 09fc68e
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 @@ -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) {
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 09fc68e

Please sign in to comment.