在ng-include指令中包含子元素

时间:2016-12-16 12:50:53

标签: javascript jquery angularjs

我将脚本标记中的模板包含在HTML DOM中。

<script type="text/ng-template" id="/tpl.html">
  <p>Content of the template.</p>
</script>


<div ng-include src="'/tpl.html'"><p>This should also be included</p></div>

现在,当包含模板时,<p>元素将被删除。我希望

内容与/tpl.html

的HTML一起使用

1 个答案:

答案 0 :(得分:0)

试图包括什么? p标签位于脚本元素???

创建新模板tpl.html

<div>
 <p>Content of the template.</p>
</div>

<div ng-include ="'/tpl.html'"><p>This should also be included</p></div>

这是角度......的工作原理。