本文介绍了AngularUI Datepicker 动态日期禁用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 AngularUI 日期选择器.

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)

我的 plunkr:我有开始和结束日期,正如您在打开每个日期选择器时看到的那样,您不能选择高于结束日期的开始日期,反之亦然.但是,如果我将开始日期更改为 11/21,我希望结束日期的日期选择器更新,以便 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

推荐答案

可以使用 min 和 max 属性并结合观察选取器的值来做到这一点.看看 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 动态日期禁用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 13:55