1
我想將所有模板放在腳本標記中,並在我的指令中使用它們而不需要使用Ajax請求。AngularJS - 預加載的模板不能使用指令
這是我的模板:
<script id="article_row.html" type="text/ng-template">
<tr>
<td class="article-id">[[ article.id ]]</td>
<td>[[ article.title ]]</td>
<td>[[ article.user_id ]]</td>
<td>[[ article.created_at ]]</td>
<td>
<article-restore id="article.id"></article-restore>
</td>
</tr>
</script>
這是我的指令:
app.directive("articleLine", [function(){
return {
return: 'E',
scope: {
article : "=data"
},
templateUrl: "article_row.html"
};
}]);
當加載,我在控制檯中此錯誤:
Error: Failed to load template: article_row.html
而且我看到瀏覽器試圖從中獲得它的控制檯http://localhost/articles/article_row.html
而是尋找它在頁面中,我做錯了什麼?
謝謝!
請提供一個小提琴/ plunker。首先猜測沒有看到代碼是你的'