diff --git a/src/datepicker/datepicker.js b/src/datepicker/datepicker.js
index a66465147d..c1ff1a6e94 100644
--- a/src/datepicker/datepicker.js
+++ b/src/datepicker/datepicker.js
@@ -41,7 +41,7 @@ angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootst
angular.forEach(['minDate', 'maxDate'], function(key) {
if ($attrs[key]) {
$scope.$parent.$watch($attrs[key], function(value) {
- self[key] = value ? new Date(value) : null;
+ self[key] = value ? angular.isDate(value) ? new Date(value) : new Date(dateFilter(value, 'medium')) : null;
self.refreshView();
});
} else {
@@ -628,10 +628,10 @@ function(scope, element, attrs, $compile, $parse, $document, $rootScope, $positi
if (attrs[key]) {
var getAttribute = $parse(attrs[key]);
scope.$parent.$watch(getAttribute, function(value) {
- scope.watchData[key] = value;
if (key === 'minDate' || key === 'maxDate') {
- cache[key] = new Date(value);
+ cache[key] = angular.isDate(value) ? new Date(value) : new Date(dateFilter(value, 'medium'));
}
+ scope.watchData[key] = cache[key] || value;
});
datepickerEl.attr(cameltoDash(key), 'watchData.' + key);
diff --git a/src/datepicker/test/datepicker.spec.js b/src/datepicker/test/datepicker.spec.js
index 972bb57a8c..e112144823 100644
--- a/src/datepicker/test/datepicker.spec.js
+++ b/src/datepicker/test/datepicker.spec.js
@@ -965,6 +965,20 @@ describe('datepicker', function() {
});
+ describe('`min-date` attribute', function () {
+ beforeEach(function() {
+ element = $compile('