Angular bootstrap ui timepicker无法找到模板

时间:2015-10-21 10:51:47

标签: angularjs datepicker angular-ui-bootstrap

我使用datepicker的模板构建了bootstrap-custom.js版本,尽管该文件包含如下模板:

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" +
    "  <uib-daypicker ng-switch-when=\"day\" tabindex=\"0\"></uib-daypicker>\n" +
    "  <uib-monthpicker ng-switch-when=\"month\" tabindex=\"0\"></uib-monthpicker>\n" +
    "  <uib-yearpicker ng-switch-when=\"year\" tabindex=\"0\"></uib-yearpicker>\n" +
    "</div>");
}]);

我叫这个js。从我的index.html正确归档,我收到以下错误:

Error: [$compile:tpload] Failed to load template: template/datepicker/datepicker.html

我认为我必须更改它的路径,但是为了正确引用模板,我需要更改什么?

感谢任何帮助,谢谢。

编辑1

自举-custom.js

angular.module("ui.bootstrap.tpls", ["template/datepicker/datepicker.html","template/datepicker/day.html","template/datepicker/month.html","template/datepicker/popup.html","template/datepicker/year.html","template/timepicker/timepicker.html"]);
angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootstrap.position'])

1 个答案:

答案 0 :(得分:0)

所以看起来我对第一条评论的猜测是正确的

因为您将模板定义为不同的模块,您需要将该模块直接或间接(通过其他模块)包含到您的主应用程序中

直接包括

angular.module("myUberApp", ["template/datepicker/datepicker.html"]);

间接包括

angular.module("myUberApp", ["myOtherModule"]);
angular.module("myOtherModule", ["template/datepicker/datepicker.html"]);