angular ui datepicker 刷新禁用日期 [英] angular ui datepicker refresh disabled dates

查看:30
本文介绍了angular ui datepicker 刷新禁用日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人有从服务器响应中更新 angular ui 的禁用日期的解决方案?

Does anyone have a solution to updating angular ui's disabled dates from a server response?

https://github.com/angular-ui/bootstrap/issues/779

您应该创建另一个需要 datepicker 控制器的指令.从你的指令,您应该调用日期选择器的 refreshView 来重新评估禁用的日期.

You should create another directive that will require datepicker's controller. From your directive you should call the refreshView of the datepicker to reevalute the disabled dastes.

有人有这方面的示例代码吗?

Does anyone have example code for that?

我正在尝试使用 angular ui datepicker,以便从服务器响应中读取禁用的日期.我更改了日期选择器的最小日期以强制其刷新.

I'm trying to use angular ui datepicker so that the disabled dates are read from a server response. I change the datepicker's min date to force it to refresh.

我看到另一个 stackoverflow 页面,用户在其中刷新了它,但它依赖于单击的日期选择器日历.另一个使用将日期最小值属性设置为另一个字段的值.

I saw another stackoverflow page where the user had it refresh, but it relied on the datepicker calendar being clicked. Another one used set the date min attribute as the value of another field.

对我来说,我有一个与日期选择器完全不同的字段.更改时,它会向服务器发送一个 http 请求,如果响应成功,可用日期将更新.

For me, I have a completely separate field from the date picker. When changed, it sends an http request to the server, and on a successful response the available dates are updated.

更改最小日期以强制刷新的唯一问题是有时相同但要禁用的日期不同.我正在考虑将我不使用的日期选择器选项更改为随机值以强制刷新.

The only problem with changing the min date to force a refresh is that sometime's there same but with different dates to disable. I'm looking into changing a datepicker option I do not use to a random value to force a refresh.

有没有更好的办法?我看到了通过服务进行的跨控制器通信,但这是一个不同的模块.我还看到了一个 github 问题,其中 datepicker 控制器可以是

Does anyone have a better way? I saw cross controller communication via a service, but this is a different module. I also saw a github issue where the datepicker controller can be

推荐答案

angular bootstrap datepicker 有 datepicker-options

The angular bootstrap datepicker has datepicker-options

该用户列出了解决方案:https://github.com/angular-ui/bootstrap/issues/2189#issuecomment-225685104

This user listed the solution: https://github.com/angular-ui/bootstrap/issues/2189#issuecomment-225685104

bogdandrumen 于 6 月 13 日发表评论

bogdandrumen commented on Jun 13

Use datepicker-options="{minDate: yourScopeMinDate}"

这对我有用.我有两个选择器,第二个选择器不能大于第一个,所以如果第一个选择器改变,第二个选择器的最大日期也会改变.

which worked for me. I have two pickers, the second picker cannot be greater than the first one so if the first picker changes, the second picker's max date also changes.

这篇关于angular ui datepicker 刷新禁用日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆