diff --git a/src/datepicker/datepicker.js b/src/datepicker/datepicker.js index c597bbf1d0..87f93683bf 100644 --- a/src/datepicker/datepicker.js +++ b/src/datepicker/datepicker.js @@ -629,7 +629,16 @@ function(scope, element, attrs, $compile, $parse, $document, $rootScope, $positi scope.$parent.$watch(getAttribute, function(value) { scope.watchData[key] = value; if (key === 'minDate' || key === 'maxDate') { - cache[key] = new Date(value); + var date = parseDate(value); + if(!date) { + var tryDate = new Date(value); + if(angular.isDate(tryDate) && !isNaN(tryDate)) { + dateArray = tryDate.toISOString().split('T')[0].split('-'); + date = new Date(+dateArray[0], +dateArray[1] - 1, +dateArray[2]); + } + } + scope.watchData[key] = date; + cache[key] = date; } }); datepickerEl.attr(cameltoDash(key), 'watchData.' + key); diff --git a/src/datepicker/test/datepicker.spec.js b/src/datepicker/test/datepicker.spec.js index cc20d15926..1b97feb9af 100644 --- a/src/datepicker/test/datepicker.spec.js +++ b/src/datepicker/test/datepicker.spec.js @@ -1948,6 +1948,17 @@ describe('datepicker directive', function() { expect(buttons.eq(0).prop('disabled')).toBe(true); }); + it('should disable today button if before min date, literal case', function() { + var minDate = new Date(new Date().setDate(new Date().getDate() + 1)); + var literalMinDate = minDate.toISOString().split('T')[0]; + var wrapElement = $compile('