通过它的选择器或参考来显示组件

时间:2018-02-16 16:09:02

标签: angular angular-components

容器component.ts

export class ContainerComponent{
    innerComponentRef; //We have this
    innerComponentSelector;//We have this
    }

但是在container-component.html中,我不知道如何使用innerComponent标记追加html。字符串插值 - 无法确定。我也想知道我想做的不是一种不好的做法。

1 个答案:

答案 0 :(得分:-1)

如果您在NgModule中的declarations: []内注册组件,则可以在container-component.html中执行以下操作:

<div>
    <innerComponentRef></innerComponentRef>
    <innerComponentSelector></innerComponentSelector>
</div>

更改innerComponentRef名称的innerComponentSelectorselector: ""