[英]AngularJS 1.6.7 custom directive not rendering
我正在学习AngularJS,并试图创建一个自定义指令。 在我的index.html文件中,我有以下内容
<h3><product-title></product-title></h3>
在我的app.js文件中,我有:
var app = angular.module('store', []);
app.directive('productTitle', function(){
return {
restrict: 'E',
templateUrl: 'product-title.html'
};
});
product-title.html
与html文件位于同一目录中,并且我也在Apache服务上运行该目录,因此Angular的Ajax调用应该不会有任何问题。 模板由于某种原因未呈现。 有谁知道是什么问题吗? 另外,请注意,控制台未显示任何错误,并且网络未显示对product-title.html
的调用。 我的index.html
文件中也有ng-app="store"
。
在product-title.html
{{product.name}}
<em class="pull-right">{{product.price | currency}}</em>
这是一个缓存问题。 清除缓存(使用开发人员工具)解决了该问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.