缺少 Angular ui bootstrap 指令模板 [英] Angular ui bootstrap directive template missing

查看:35
本文介绍了缺少 Angular ui bootstrap 指令模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在我的机器上本地测试 angular bootstrap-UI.当我尝试重新创建手风琴和对话框的示例时.我在控制台中收到此错误消息,说缺少模板.

I'm currently testing out angular bootstrap-UI locally on my machine. When I try to recreate the example of accordion and dialog box. I get this error message in my console saying that template is missing.

错误示例:404 未找到 - localhost/angular/template/message.html

Example of error: 404 Not Found - localhost/angular/template/message.html

当我查看 ui-bootstrap-0.1.0.js 时,指令有一个模板 URL.

When I look into ui-bootstrap-0.1.0.js the directive have a template URL.

templateURL 指令的目的是什么?

当我下载整个 Angular bootstrap-UI zip 文件时,是否假设包含这些模板?

Are those template suppose to be included when I download the whole angular bootstrap-UI zip file?

我是否遗漏了其他应该包含在标题中的文件?

Am I missing other files that I should have include in my header?

<link rel="stylesheet" href="includes/css/bootstrap.css">
<script src="includes/js/angular.js"></script>
<script src="includes/js/ui-bootstrap-0.1.0.js"></script>

推荐答案

您有两个选择:

  1. 如果您不想制作自己的模板而想要内置模板,您应该下载 ui-bootstrap-tpls-0.1.0.js 文件 - 这会注入所有模板,以便它们预先缓存到您的应用程序中:https://github.com/angular-ui/bootstrap/blob/gh-pages/ui-bootstrap-tpls-0.1.0.js#L1322

  1. If you don't want to make your own templates and want the built in ones, you should download the ui-bootstrap-tpls-0.1.0.js file - this injects all the templates so they are pre-cached into your app: https://github.com/angular-ui/bootstrap/blob/gh-pages/ui-bootstrap-tpls-0.1.0.js#L1322

如果您确实想制作一些自己的模板,请在您的应用中创建一个 templates 文件夹,然后从 angular-ui/bootstrap 项目下载模板.然后覆盖您要自己自定义的那些.

If you do want to make some of your own templates, create a templates folder in your app, and download the templates from the angular-ui/bootstrap project. Then overwrite the ones you want to customize on your own.

在此处阅读更多信息:https://github.com/angular-ui/bootstrap/tree/gh-pages#build-files

编辑:

你也可以下载 bootstrap-tpls.js 并仍然用你自己的覆盖指令的一些 templateUrls,使用 AngularJS 装饰器来改变指令的 templateUrl.这是更改日期选择器的 templateUrl 的示例:

You can also download bootstrap-tpls.js and still overwrite some of the directive's templateUrls with your own, using an AngularJS decorator to change the directive's templateUrl. Here's an example that change's datepicker's templateUrl:

http://docs.angularjs.org/api/AUTO.$provide#methods_decorator

myApp.config(function($provide) {
  $provide.decorator('datepickerDirective', function($delegate) {
    //we now get an array of all the datepickerDirectives, 
    //and use the first one
    $delegate[0].templateUrl = 'my/template/url.html';
    return $delegate;
  });
});

这篇关于缺少 Angular ui bootstrap 指令模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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