angular-ui / bootstrap

PLEASE READ THE PROJECT STATUS BELOW. Native AngularJS (Angular) directives for Bootstrap. Smaller footprint (20kB gzipped), no 3rd party JS dependencies (jQuery, bootstrap JS) required. Please read the README.md file before submitting an issue!
http://angular-ui.github.io/bootstrap/
MIT License
14.27k stars 6.73k forks source link

datepicker-popup: Cannot change maxDate and minDate option on the fly #6376

Open wbarnie opened 7 years ago

wbarnie commented 7 years ago

Bug description: Cannot change maxDate and minDate option on the fly

I have page with 2 date pickers, start date and end date. Start date can be min date today max date today plus 90 days. End date min date is start date plus 1 hour and max date is start date plus 30. o have a structure and initially set it as follows:

maxDateSeed = new Date(); maxDateSeed.setDate(maxDateSeed.getDate() + 30); var minDateSeed = new Date(); minDateSeed.setHours(minDateSeed.getHours() + 1);

$scope.endDateOptions = { minDate: minDateSeed, maxDate: maxDateSeed }; $scope.endTimeOptions = { minuteStep: 5 };

When the begin date changes, i do the following:

var defaultDate; var minDate; var maxDate;

     maxDate = new Date($scope.schedule.start_date);
      minDate = new Date($scope.schedule.start_date);
      defaultDate = new Date($scope.schedule.start_date);

minDate.setHours(minDate.getHours() + 1);

    defaultDate.setDate(defaultDate.getDate() + 3);

    maxDate.setDate(maxDate.getDate() + 30);
    $scope.endDateOptions.minDate = minDate;
    $scope.endDateOptions.maxDate = maxDate;

The correct date is displayed but the allowable range is wrong it is still the original date range. How can i change maxDate and minDate option on the fly?

here is a url to a plunker example that some else had the same issue. This example was supposed to show how this work but it does not work.

Version of Angular: ~1.4.0 UIBS: ~2.4.0 Bootstrap: ~3.3.4

Angular:

UIBS:

Bootstrap:

mbostwick commented 7 years ago

The issue, is they are not doing dirty checking on the watch of the date object. If you use literals you'll get a warning, but the scope trigger will occur.