Search code examples
angularjsdatepickerangular-uiangular-ui-bootstrap

AngularUI Datepicker dynamic date disabling


I am using the AngularUI datepicker.

I have two datepickers that influence each other. One is for example a "start date" and the other is an "end date". Instead of creating validation for both datepickers, I want to eliminate the option of having invalid dates (i.e. end date earlier than the start date and vice versa).

Is there a way to re-trigger the date-disabled attribute on select of a date? (re-trigger the date-disabled of the OTHER datepicker)

My plunkr: I have a start and end date, as you can see when you open each date picker, you cannot pick a start date higher than the end date and vice versa. However if I change my start date to 11/21, I want the end date's datepicker to update so that the 11/20 is no longer clickable. Is there any way to do this?

http://plnkr.co/edit/TgisJnSwQItDeCuIReLL?p=preview


Solution

  • It is possible to do this using min and max attributes in combination with watching pickers' values. Look at http://plnkr.co/edit/W5pb1boMLOHZFnWkMU8o?p=preview