2

我想將數據綁定到角模板。但我正面臨以下問題。將數據綁定到模板定義在<script> AngularJS中的標記

我正在使用$ templateCache檢索模板,但找不到數據到模板中。

$templateCache.get('q1.index.html'); 

現在,我也試圖做$compile($templateCache.get('q1.index.html'));但我正在逐漸Error: [jqLite:nosel] http://errors.angularjs.org/1.3.14/jqLite/nosel錯誤。

有人可以讓我知道我在做什麼錯了&我該如何解決它。

+0

檢索您可以添加完整代碼或者至少將$ templateCache注入你的ang的JS ular控制器? –

回答

0

您需要使用這種格式爲您<script>標籤

<script type="text/ng-template" id="templateId.html"> 
    <p>This is the content of the template</p> 
</script> 

然後在其他地方,你可以用$templateCache

$templateCache.get('templateId.html') 

或通過ng-include

<div ng-include="'templateId.html'"></div> 
相關問題