今天在學(xué)習(xí)angularJS的時(shí)候,影片講到ng-include的用法。
說白了也就是把通用的html程式碼提取到一個(gè)html檔案裡面再include進(jìn)去而已。
但是當(dāng)我在index.html引進(jìn)同一目錄下的product-title.html時(shí),卻不顯示product-title.html裡面的內(nèi)容。
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>
看調(diào)試介面產(chǎn)生的是:
<!-- ngInclude: a.html -->
這麼一句話。
走同樣的路,發(fā)現(xiàn)不同的人生
ng-include的值必須是變量,不能是檔名。將檔案路徑賦值給一個(gè)變量,再ng-include='變數(shù)名'