角UI日期选择器刷新禁用日期 [英] angular ui datepicker refresh disabled dates

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

问题描述

有没有人有一个解决方案从服务器响应更新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

您应该创建另一个指令,要求日期选择器的控制器。从你的
  指令应该叫日期选择器的refreshView到reevalute残疾人dastes。

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.

有没有人有例如code是什么?

Does anyone have example code for that?

我试图用角UI日期选择器,使残疾人日期是从服务器响应读取。我更改了日期选择器的分日期,迫使它刷新。

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.

我看到了另一个计算器的页面,用户必须刷新它,但它依赖于被点击的日期选择器日历。另一种中设置min属性的时间作为另一字段的值。

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.

与改变敏时间强制刷新唯一的问题是,有时的有相同,但不同的日期禁用。我期待到不断变化的,我不使用一个随机值强制刷新一个datepicker选择。

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的问题,即日期选择器控制器可以

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

推荐答案

我已经找到了一个简单的解决这个问题,使用装饰:的 https://gist.github.com/cgmartin/3daa01f910601ced9cd3

I've found a simple solution to this problem using a decorator: https://gist.github.com/cgmartin/3daa01f910601ced9cd3

然后,您只需要调用 $范围。$广播('refreshDatepickers')刷新datepickers。

Then, you only need to call $scope.$broadcast('refreshDatepickers') to refresh the datepickers.

重要信息:对于最近的 UI-引导日期选择库,您可能需要更换'datepickerDirective 'uibDatepickerDirective 如果您正在使用日期选择器与 UIB-日期选择器元素或属性。

IMPORTANT: For more recent ui-bootstrap datepicker library, you may need to replace 'datepickerDirective' with 'uibDatepickerDirective' if you are using datepicker with uib-datepicker element or attribute.

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

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