Angular 防止渲染外部组件标记

Angular 防止渲染外部组件标记,angular,Angular,我正在将组件导入我的页面: <div> <p>Here is my component:</p> <my-component></my-component> </div> 以下是我的组件: 如何防止在标记中呈现的物理HTML,而只使用my component模板中声明的HTML 现在我得到: <div> <p>Here is my component:</p>

我正在将组件导入我的页面:

<div>
<p>Here is my component:</p>
<my-component></my-component>
</div>

以下是我的组件:

如何防止在标记中呈现
的物理HTML,而只使用my component模板中声明的HTML

现在我得到:

    <div>
    <p>Here is my component:</p>
    <my-component><div>This is the inner html</div></my-component>
    </div>

以下是我的组件:

这是内部html
鉴于我想要:

        <div>
        <p>Here is my component:</p>
        <div>This is the inner html</div>
        </div>

以下是我的组件:

这是内部html
在组件定义中,您可以设置
选择器:“[我的组件]”
,并将其视为指令,即

<div my-component>This is the inner html</div>
这是内部html

然后组件标记将不会显示。

在组件定义中,您可以设置
选择器:“[my component]”
,并将其视为指令,即

<div my-component>This is the inner html</div>
这是内部html

那么组件标签就不会出现。

Aw太好了!非常感谢:)哦,太好了!非常感谢:)