我如何获得" Type"将组件传递给:
loadIntoLocation(type: Type, hostLocation: ElementRef, anchorName: string)
我想通过孩子的 @Input 传递类型:
<searchComponent [componentToLoad]="component"></searchComponent>
答案 0 :(得分:3)
您可以为变量指定类型:
@Component({
selector: 'dyn-cmp',
template: `
`})
class DynCmp {
}
@Component({
selector: 'parent-cmp',
template: `
<searchComponent [componentToLoad]="dynCmp"></searchComponent>
`})
class ParentCmp {
dynCmp:Type = DynCmp;
}