加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angular 2包括html模板

发布时间:2020-12-17 07:58:51 所属栏目:安全 来源:网络整理
导读:在角度2我需要创建一个带有冗余部分的大型html模板. 因此,我想创建多个html模板,并将它们包含在主html文件中(如angular1中的ng-include) 但是如何在主模板中包含子模板? 例: !-- test.html --div this is my Sub-Item !-- include sub1.html here--/divdiv
在角度2我需要创建一个带有冗余部分的大型html模板.
因此,我想创建多个html模板,并将它们包含在主html文件中(如angular1中的ng-include)

但是如何在主模板中包含子模板?

例:

<!-- test.html -->

<div>
    this is my Sub-Item
    <!-- include sub1.html here-->
</div>
<div>
    this is second Sub-Item
    <!-- include sub2.html here-->
</div>

<!-- sub1.html -->
<div>
    <button>I'am sub1</button>
</div>

<!-- sub2.html -->
<div>
    <div>I'am sub2</div>
</div>
您可以创建sub1 sub2等组件.在这些子组件上添加这些html文件作为模板.

在主html上分别调用组件选择器.它会工作

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读