如何在angular中的子组件中插入html?
我正在尝试将html插入子组件中。基本上是这样的:如何在angular中的子组件中插入html?,angular,typescript,Angular,Typescript,我正在尝试将html插入子组件中。基本上是这样的: Parnet内容 我可以找到将数据传递给子组件的引用,但无法找到如何在选择器中传递实际的html?ng内容标记可以在子组件的模板中使用。该标记将接收您在组件选择器之间输入的任何内容。您也可以将与选择属性一起使用 父组件: <child-component> <div sample>Content form parent</div> </child-component> something
Parnet内容
我可以找到将数据传递给子组件的引用,但无法找到如何在选择器中传递实际的html?ng内容标记可以在子组件的模板中使用。该标记将接收您在组件选择器之间输入的任何内容。您也可以将
与选择属性一起使用
父组件:
<child-component>
<div sample>Content form parent</div>
</child-component>
something..
<ng-content select="[sample]"></ng-content>
some more...
something..
<div>Content from parent</div>
some more...
内容表单父级
子组件:
<child-component>
<div sample>Content form parent</div>
</child-component>
something..
<ng-content select="[sample]"></ng-content>
some more...
something..
<div>Content from parent</div>
some more...
什么。。
还有一些。。。
输出:
<child-component>
<div sample>Content form parent</div>
</child-component>
something..
<ng-content select="[sample]"></ng-content>
some more...
something..
<div>Content from parent</div>
some more...
什么。。
来自家长的内容
还有一些。。。
更多细节