@@ -513,14 +513,28 @@ function($compile, $parse, $document, $rootScope, $position, dateFilter, datePar
513
513
appendToBody = angular . isDefined ( attrs . datepickerAppendToBody ) ? scope . $parent . $eval ( attrs . datepickerAppendToBody ) : datepickerPopupConfig . appendToBody ,
514
514
onOpenFocus = angular . isDefined ( attrs . onOpenFocus ) ? scope . $parent . $eval ( attrs . onOpenFocus ) : datepickerPopupConfig . onOpenFocus ,
515
515
datepickerPopupTemplateUrl = angular . isDefined ( attrs . datepickerPopupTemplateUrl ) ? attrs . datepickerPopupTemplateUrl : datepickerPopupConfig . datepickerPopupTemplateUrl ,
516
- datepickerTemplateUrl = angular . isDefined ( attrs . datepickerTemplateUrl ) ? attrs . datepickerTemplateUrl : datepickerPopupConfig . datepickerTemplateUrl ;
516
+ datepickerTemplateUrl = angular . isDefined ( attrs . datepickerTemplateUrl ) ? attrs . datepickerTemplateUrl : datepickerPopupConfig . datepickerTemplateUrl ,
517
+ cache = { } ;
517
518
518
519
scope . showButtonBar = angular . isDefined ( attrs . showButtonBar ) ? scope . $parent . $eval ( attrs . showButtonBar ) : datepickerPopupConfig . showButtonBar ;
519
520
520
521
scope . getText = function ( key ) {
521
522
return scope [ key + 'Text' ] || datepickerPopupConfig [ key + 'Text' ] ;
522
523
} ;
523
524
525
+ scope . isDisabled = function ( date ) {
526
+ if ( date === 'today' ) {
527
+ date = new Date ( ) ;
528
+ }
529
+
530
+ return ( ( scope . watchData . minDate && scope . compare ( date , cache . minDate ) < 0 ) ||
531
+ ( scope . watchData . maxDate && scope . compare ( date , cache . maxDate ) > 0 ) ) ;
532
+ } ;
533
+
534
+ scope . compare = function ( date1 , date2 ) {
535
+ return ( new Date ( date1 . getFullYear ( ) , date1 . getMonth ( ) , date1 . getDate ( ) ) - new Date ( date2 . getFullYear ( ) , date2 . getMonth ( ) , date2 . getDate ( ) ) ) ;
536
+ } ;
537
+
524
538
var isHtml5DateInput = false ;
525
539
if ( datepickerPopupConfig . html5Types [ attrs . type ] ) {
526
540
dateFormat = datepickerPopupConfig . html5Types [ attrs . type ] ;
@@ -591,6 +605,9 @@ function($compile, $parse, $document, $rootScope, $position, dateFilter, datePar
591
605
var getAttribute = $parse ( attrs [ key ] ) ;
592
606
scope . $parent . $watch ( getAttribute , function ( value ) {
593
607
scope . watchData [ key ] = value ;
608
+ if ( key === 'minDate' || key === 'maxDate' ) {
609
+ cache [ key ] = new Date ( value ) ;
610
+ }
594
611
} ) ;
595
612
datepickerEl . attr ( cameltoDash ( key ) , 'watchData.' + key ) ;
596
613
0 commit comments