【问题标题】:ui-bootstrap Datepicker not workingui-bootstrap 日期选择器不工作
【发布时间】:2014-04-07 15:52:18
【问题描述】:

我正在尝试为日期选择器创建指令,但弹出窗口不起作用(无论是单击文本字段还是按钮)

Plunker:http://plnkr.co/edit/hUxQASblscbhFZFvWDyN

p.d:想法是从控制器中删除所有日期选择器代码(因为日期选择器将在许多控制器中使用),所以请不要建议将打开和关闭功能移至页面控制器。

【问题讨论】:

  • 我注意到,如果您尝试从 index.html 调用 datepicker 指令,它就不起作用。我还在寻找,但我建议先让这个基本示例工作,然后在你自己的指令中增加复杂性。
  • angular.module('foo', ['ui.bootstrap'])
  • 是的,我忘记了模块中的注入,无论如何问题仍然存在。 Plunker 更新

标签: angularjs angular-ui-bootstrap


【解决方案1】:

我不确定这是否会让您一路实现目标,但我认为您面临的障碍是您在创建“foo”应用程序时忘记导入 ui.bootstrap。

http://plnkr.co/edit/ZGl0VuJjVF1nliMidaL6

【讨论】:

  • 我用导入更新了我的 plunker,但没有工作。您的工作正常,您是否更改了其他内容?
  • 我在您的文章中看到的唯一另一件事是输入标签中的日期选择器弹出窗口。 "datepicker-popup (Default: 'yyyy-MM-dd') : 显示日期的格式。"
  • 是的,它是日期选择器弹出窗口(奇怪,如果您以“标准”方式使用日期选择器,则不需要)。还发现了另一个问题,我的控制器包含一个未定义的配置模块(它是我项目中原始代码的剩余部分)。谢谢!
  • 当然!此问题可能与此处讨论的问题有关:github.com/angular-ui/bootstrap/pull/1809
【解决方案2】:

确保您在标记中定义了 is-open 属性。

<input type="text" class="form-control" datepicker-popup="date.format" ng-model="date.selectedDate" max-date="date.maxDate" datepicker-options="date.dateOptions" date-disabled="date.disabled(date, mode)" ng-required="true" close-text="Close" show-weeks="false" is-open="date.opened" ng-focus="date.opened=true" />

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-12-02
    • 2013-10-29
    • 1970-01-01
    • 2012-09-22
    • 2018-06-14
    • 1970-01-01
    • 1970-01-01
    • 2021-12-14
    相关资源
    最近更新 更多