【发布时间】:2016-08-07 02:21:36
【问题描述】:
我尝试包含一个带有角度ng-include 的模板。要包含的页面:
<table class="table table-hover table-striped">
<thead>
<tr>
<th translate>
First
</th>
<th translate>
Second
</th>
<th translate>
Third
</th>
</tr>
</thead>
<tbody>
<ng-include src="getTemplate('default')"></ng-include>
</tbody>
</table>
模板:
<tr class="table-row-clickable">
<td>text1</td>
<td>text2</td>
<td>text3</td>
</tr>
获取模板方法:
$scope.getTemplate = function(templateName) {
return APP_CONFIG.TPL_PATH + '/path/' + templateName + '.html';
};
模板加载正常,我可以在页面上看到它,但在错误的位置。这是我浏览器控制台的屏幕,ng-include 在表格之前插入,而不是在表格内部:
请您帮我理解一下,这是为什么呢?提前谢谢你。
【问题讨论】:
-
我会直接将 ng-include 放在 tbody 标签上,即
<tbody ng-include></tbody> -
我正要写下@Dwardu 所说的内容。 ng-include 不使用“替换”,所以我认为浏览器可能会认为它在错误的位置并将其移到外面
标签: javascript angularjs angularjs-ng-include