AngularUI Datepicker动态日期禁用 [英] AngularUI Datepicker dynamic date disabling
问题描述
我正在使用AngularUI datepicker。
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).
有没有办法在选择日期时重新触发日期禁用属性? (重新触发OTHER datepicker的日期禁用)
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)
我的朋友:我有一个开始和结束日期,你可以看到当你打开每个日期选择器,您不能选择高于结束日期的开始日期,反之亦然。但是,如果我将开始日期更改为11/21,我希望更新结束日期的datepicker以使11/20不再可点击。有没有办法这样做?
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
推荐答案
可以这样做使用最小和最大属性结合观看选择器的值。
查看 http://plnkr.co/edit/W5pb1boMLOHZFnWkMU8o?p=preview
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
这篇关于AngularUI Datepicker动态日期禁用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!