簡體   English   中英

AngularJS 1.6.7自定義指令未渲染

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM