【发布时间】:2018-07-01 21:22:02
【问题描述】:
使用以下html:
<div [ngSwitch]="type">
<my-component-a *ngSwitchCase="'A'"></my-component-a>
<my-component-b *ngSwitchCase="'B'"></my-component-b>
<my-component-c *ngSwitchCase="'C'"></my-component-c>
<my-component-d *ngSwitchDefault></my-component-d>
</div>
如何在 ts 代码中获取对所选组件的引用?例如
public getChosenComponent(): MyComponentBase {
return ???;
}
【问题讨论】: