从数组循环渲染组件

用户名

在我的app.component.ts中,我有一个带有元件标签的数组。

compData = ['app-component-one', 'app-component-two', 'app-component-three'];

然后在我的app.component.html中,我有这个:

<div *ngFor="let comps of compData">

    // I tried this: {{comps}} but that will not render the components

</div>

我该如何做才能渲染每个组件?

萨耶塔兰(Sajeetharan)

您不能从数组中渲染组件,而是需要查看动态组件生成器

https://angular.io/guide/dynamic-component-loader

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章