奇怪的angular-ui datepicker依赖性错误

时间:2015-02-19 22:03:51

标签: angularjs datepicker angular-bootstrap

刚刚重新安装了一些bower组件,但这里讨论的组件没有更新,同样0.12.0 ui.bootstrap。同时使用ui-router 0.2.13将状态更改为其他页面。

奇怪的错误信息是

Error: [$compile:ctreq] Controller 'datepicker', required by directive 'daypicker', can't be found!

但是当我查看ui-bootstrap-tpls.js文件时,datepicker控制器直接在daypicker上面定义,应该被选中。

这可能是因错误的datepicker类别名称错误造成的吗?

我知道这不是很多,但会更新,因为我有时间添加代码。似乎某处可能存在冲突的datepicker。它只发生在从一个页面到另一个页面的stateChange上。使用datepicker的完整流程可以正常工作,直到最后一页。如果控制器依赖项在同一个文件中,它如何被错过?

如果有人以前见过这个,我会很感激任何指导。

更新4月23日15:正在使用一个模式对话框,其中一个表单可以将用户发送到另一个页面,然后点击OK。

3 个答案:

答案 0 :(得分:1)

我将此错误更新为ui.bootstrap 0.14.x。

我在自己的模块中覆盖了导致问题的模板:

    angular.module("template/datepicker/datepicker.html", []).run(["$templateCache", function ($templateCache) {
    $templateCache.put("template/datepicker/datepicker.html",
      "<div ng-switch=\"datepickerMode\" role=\"application\" ng-keydown=\"keydown($event)\">\n" +
      "  <daypicker ng-switch-when=\"day\" tabindex=\"0\"></daypicker>\n" +
      "  <monthpicker ng-switch-when=\"month\" tabindex=\"0\"></monthpicker>\n" +
      "  <yearpicker ng-switch-when=\"year\" tabindex=\"0\"></yearpicker>\n" +
      "</div>");
    }]);

删除模块后再次工作。

最初我更改了使用font-awesome图标而不是glyphicons的模板。现在我重写glyphicon css类以更改为font-awesome图标:

.glyphicon {
    font: normal normal normal 14px/1 ourIconFont;
}
.glyphicon-arrow-right:before,
.glyphicon-chevron-right:before {
    content: "\f054";
}
.glyphicon-arrow-left:before,
.glyphicon-chevron-left:before {
    content: "\f053";
}

答案 1 :(得分:0)

您需要将ui.bootstrap.0.12.0.js更新为ui-bootstrap-tpls-0.13.3.js

答案 2 :(得分:0)

出现同样的问题,我们的解决方案是在升级到uib 0.14之后我们有了一个自定义模板用于datepicker,并且必须将uib-前缀添加到datepicker(day,month year)内的子指令中。例如

<div ng-switch="datepickerMode" role="application" ng-keydown="keydown($event)">
  <daypicker ng-switch-when="day" tabindex="0"></daypicker>
  <monthpicker ng-switch-when="month" tabindex="0"></monthpicker>
  <yearpicker ng-switch-when="year" tabindex="0"></yearpicker>
</div>

已更改为

<div ng-switch="datepickerMode" role="application" ng-keydown="keydown($event)">
  <uib-daypicker ng-switch-when="day" tabindex="0"></uib-daypicker>
  <uib-monthpicker ng-switch-when="month" tabindex="0"></uib-monthpicker>
  <uib-yearpicker ng-switch-when="year" tabindex="0"></uib-yearpicker>
</div>