我是angularjs的新手,我按照angularjs的script文档创建了一个非常简单的模板脚本标签,但它根本不起作用,下面是代码和{{3 }}。
<div ng-app>
<table>
<ng-include src="tpl.html"></ng-include>
</table>
<div ng-include src="tpl2.html"></div>
<script type="text/ng-template" id="tpl.html">
<tr>
<td>ACBC</td>
</tr>
</script>
<script type="text/ng-template" id="tpl2.html">
test
</script>
</div>
我的代码有问题吗?
答案 0 :(得分:1)
将网址放在单引号中
src="'tpl.html'"
`
<script type="text/ng-template" id="tpl.html">
<tr>
<td>ACBC</td>
</tr>
</script>
<script type="text/ng-template" id="tpl2.html">
test
</script>
请参阅小提琴更新 `http://jsfiddle.net/U3pVM/15840/
答案 1 :(得分:0)
你错过了<td></td>
元素:)
这就是你应该如何实现你的代码
<div ng-app>
<table>
<tr ng-repeat="i in [1,2,3,4,5,6]">
<td>
<ng-include src="'tpl.html'"></ng-include>
</td>
</tr>
</table>
<div ng-include src="'tpl2.html'"></div>
<script type="text/ng-template" id="tpl.html">
<td>ACBC</td>
</script>
<script type="text/ng-template" id="tpl2.html">
test
</script>