除了在模板中直接使用组件外,您还可以动态渲染组件。动态渲染组件主要有两种方式:在模板中使用 NgComponentOutlet,或在 TypeScript 代码中使用 ViewContainerRef。
NgComponentOutlet
ViewContainerRef