文章詳情頁
angular.js - angular使用ng-include,為什么生成不了html代碼
瀏覽:124日期:2024-03-18 17:31:40
問題描述
今天在學習angularJS的時候,視頻講到ng-include的用法。說白了也就是把通用的html代碼提取到一個html文件里面再include進去而已。
但是我在index.html引入同一目錄下的product-title.html時,卻不顯示product-title.html里面的內容。
angular版本是1.4.8
index.html:
<h3 ng-include='’product-title.html’'></h3>
product-title.html:
{{product.name}}<em class='pull-right'>{{product.price | currency}}</em>
看調試界面生成的是:
<!-- ngInclude: a.html -->
這么一句話。
問題解答
回答1:是因為沒有把頁面放在http服務器上運行。
回答2:是不是路徑有問題?你看一下product-title.html和index.html是不是同一級別。
回答3:瀏覽器中看看,html是404還是? 即確認文件路徑~
回答4:ng-include的值必須是一個變量,不能是文件名。將文件路徑賦值給一個變量,再ng-include=’變量名’
標簽:
HTML
排行榜
