角指令templateURL没有被加载。为什么? [英] Angular directive templateURL not being loaded. Why?
问题描述
我创建了一个角指令。该指令汇总当我使用模板
属性。使用时,它不会编译 templateURL
。
I've created a directive in Angular. The directive 'compiles' when I use the template
attribute. It doesn't compile in when using templateURL
.
该templateURL文件不能在404页棱角分明的控制台或网络选项卡。这是200的浏览器URL。
The templateURL file doesn't 404 in angular page's console or network tab. It is 200 as a browser URL.
我是什么失踪?
'use strict';
angular.module('mean.profile').directive('inProfileSidebar', function() {
return {
restrict: 'A',
scope: {
data: '=',
editable: '=',
},
template: '<div><h2>inProfileNarrow</h2><div>{{data}}</div><div>{{editable}}</div></div>',
// templateURL: '/profile/views/inProfileSidebar.html',
};
});
我的应用程序的网址是:的http://本地主机:3000 /#/型材/
此URL是200:的http://本地主机:3000 /型材/查看/ inProfileSidebar.html
inProfileSidebar.html
inProfileSidebar.html
<div>
<h2>inProfileNarrow</h2>
<div>{{data}}</div>
<div>{{editable}}</div>
</div>
用于在这个HTML:
<div class="col-md-4">
<div in-profile-sidebar data="data.profile" editable="data.profile.editable"></div>
</div>
我没有看到在浏览器控制台任何错误,并没有对templateURL没有要求在浏览器的网络日志。
I don't see any errors in the browser console, and there is no request to the templateURL in the browser's network log.
它的工作原理,当我使用模板
,但不能与 templateURL
。为什么呢?
It works when I use template
, but not with templateURL
. Why?
推荐答案
我没有测试它,但咋一看,似乎你正确命名的属性。
I didnt test it, but from a quick look it seems you named the property incorrectly.
这应该是'templateUrl',而不是'templateURL'(只有'U'是大写)。
It should be 'templateUrl', NOT 'templateURL' (only the 'U' is uppercase).
这篇关于角指令templateURL没有被加载。为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!