Angularjs 自定义指令未加载模板
app.js文件:Angularjs 自定义指令未加载模板,angularjs,angularjs-directive,Angularjs,Angularjs Directive,app.js文件: var app = angular.module('fruitStore', []); app.directive('productTitle', function(){ return { restrict: 'E', templateUrl: 'product-title.html' }; }); index.html <product-title></product-title> product-title.html {
var app = angular.module('fruitStore', []);
app.directive('productTitle', function(){
return {
restrict: 'E',
templateUrl: 'product-title.html'
};
});
index.html
<product-title></product-title>
product-title.html
{{ product.name}}
<em class="pull-right">{{ product.price | currency}}</em>
但是指令没有加载模板。我遗漏了什么?您是否在网络控制台中看到任何404错误?你能给我们看一下你的目录结构吗?你确定相对url“product title.html”能从加载它的页面正确解析吗?这似乎是chrome中的一个问题。我是在mac电脑上运行的,当我运行chrome时,我会这样做:open/Applications/Google\chrome.app-args-允许文件访问它工作的文件。Chrome搞乱了AJAX。那么你一定有了cors issueNo解决方案????我也有同样的问题。