【发布时间】:2018-09-14 03:54:54
【问题描述】:
我需要使用一个变量来制作我的 app.component.html 的 Selector Tag。
假设变量名是:componentVar:string
我需要我的 app.component.html:
<componentVar></componentVar> 或 <app-componentVar></app-componentVar>
【问题讨论】:
-
您想动态创建组件?为什么你希望你的组件选择器以变量值命名?
-
我在 app-component.html 中附加了很多组件,我必须在其中设置条件以显示隐藏它们。因此,如果可以使用变量创建选择器标签,那么我将使用循环创建它们并使用条件。
-
*ngIf 没问题,但我需要使用动态值命名选择器。
标签: javascript angular typescript frontend