Skip to content

Commit 779a0da

Browse files
committed
Add $watch to dateDisabledDates
1 parent 763db6a commit 779a0da

File tree

4 files changed

+31
-7
lines changed

4 files changed

+31
-7
lines changed

dist/angular-datepicker.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,17 @@
476476
if (newValue) {
477477
setInputValue();
478478
}
479+
})
480+
, unregisterDateDisabledDatesWatcher = $scope.$watch('dateDisabledDates', function dateDisabledDatesWatcher(newValue) {
481+
if (newValue) {
482+
dateDisabledDates = $scope.$eval(newValue);
483+
484+
if (!$scope.isSelectableDate($scope.monthNumber, $scope.year, $scope.day)) {
485+
thisInput.val('');
486+
thisInput.triggerHandler('input');
487+
thisInput.triggerHandler('change');//just to be sure;
488+
}
489+
}
479490
});
480491

481492
$scope.nextMonth = function nextMonth() {
@@ -697,8 +708,8 @@
697708
if (date.getFullYear() &&
698709
!isNaN(date.getDay()) &&
699710
!isNaN(date.getMonth()) &&
700-
$scope.isSelectableDay(date) &&
701-
$scope.isSelectableDate(date) &&
711+
$scope.isSelectableDay(date.getMonth(), date.getFullYear(), date.getDay()) &&
712+
$scope.isSelectableDate(date.getMonth(), date.getFullYear(), date.getDay()) &&
702713
$scope.isSelectableMaxDate(date) &&
703714
$scope.isSelectableMinDate(date)) {
704715

@@ -959,6 +970,7 @@
959970
unregisterDateMinLimitWatcher();
960971
unregisterDateMaxLimitWatcher();
961972
unregisterDateFormatWatcher();
973+
unregisterDateDisabledDatesWatcher();
962974
thisInput.off('focus click focusout blur');
963975
angular.element(theCalendar).off('mouseenter mouseleave focusin');
964976
angular.element($window).off('click focus focusin', onClickOnWindow);

dist/angular-datepicker.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/angular-datepicker.sourcemap.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/js/angular-datepicker.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,17 @@
476476
if (newValue) {
477477
setInputValue();
478478
}
479+
})
480+
, unregisterDateDisabledDatesWatcher = $scope.$watch('dateDisabledDates', function dateDisabledDatesWatcher(newValue) {
481+
if (newValue) {
482+
dateDisabledDates = $scope.$eval(newValue);
483+
484+
if (!$scope.isSelectableDate($scope.monthNumber, $scope.year, $scope.day)) {
485+
thisInput.val('');
486+
thisInput.triggerHandler('input');
487+
thisInput.triggerHandler('change');//just to be sure;
488+
}
489+
}
479490
});
480491

481492
$scope.nextMonth = function nextMonth() {
@@ -697,8 +708,8 @@
697708
if (date.getFullYear() &&
698709
!isNaN(date.getDay()) &&
699710
!isNaN(date.getMonth()) &&
700-
$scope.isSelectableDay(date) &&
701-
$scope.isSelectableDate(date) &&
711+
$scope.isSelectableDay(date.getMonth(), date.getFullYear(), date.getDay()) &&
712+
$scope.isSelectableDate(date.getMonth(), date.getFullYear(), date.getDay()) &&
702713
$scope.isSelectableMaxDate(date) &&
703714
$scope.isSelectableMinDate(date)) {
704715

@@ -959,6 +970,7 @@
959970
unregisterDateMinLimitWatcher();
960971
unregisterDateMaxLimitWatcher();
961972
unregisterDateFormatWatcher();
973+
unregisterDateDisabledDatesWatcher();
962974
thisInput.off('focus click focusout blur');
963975
angular.element(theCalendar).off('mouseenter mouseleave focusin');
964976
angular.element($window).off('click focus focusin', onClickOnWindow);

0 commit comments

Comments
 (0)