@@ -241,15 +241,21 @@ angular.module("materialCalendar").directive("calendarMd", ["$compile", "$parse"
241241 $scope . dayTooltipFormat = $scope . dayTooltipFormat || "fullDate" ;
242242 $scope . disableFutureSelection = $scope . disableFutureSelection || false ;
243243 $scope . disableSelection = $scope . disableSelection || false ;
244-
244+
245245 $scope . sameMonth = function ( date ) {
246246 var d = angular . copy ( date ) ;
247247 return d . getFullYear ( ) === $scope . calendar . year &&
248248 d . getMonth ( ) === $scope . calendar . month ;
249249 } ;
250250
251251 $scope . isDisabled = function ( date , startDateOfMonth , noOfDays ) {
252- if ( noOfDays != 0 && date . getDate ( ) >= ( startDateOfMonth + noOfDays ) ) { return true ; }
252+ if ( noOfDays != 0 && angular . isDefined ( noOfDays ) ) {
253+ var dateStart = new Date ( $scope . calendar . year , $scope . calendar . month , startDateOfMonth ) ;
254+ var dateEnd = angular . copy ( dateStart ) ;
255+ dateEnd . setDate ( dateStart . getDate ( ) + parseInt ( noOfDays ) ) ;
256+ if ( date . getDate ( ) <= dateStart && date . getDate ( ) >= dateEnd ) { return true ; }
257+ }
258+ if ( $scope . disableSelection ) { return true ; }
253259 if ( $scope . disableFutureSelection && date > new Date ( ) ) { return true ; }
254260 return ! $scope . sameMonth ( date ) ;
255261 } ;
@@ -320,11 +326,11 @@ angular.module("materialCalendar").directive("calendarMd", ["$compile", "$parse"
320326 if ( $scope . disableFutureSelection && date > new Date ( ) ) {
321327 return ;
322328 }
323-
329+
324330 if ( $scope . disableSelection ) {
325331 return ;
326332 }
327-
333+
328334 var active = angular . copy ( $scope . active ) ;
329335 if ( angular . isArray ( active ) ) {
330336 var idx = dateFind ( active , date ) ;
0 commit comments