目前我正在用这段代码动态加载我的一些组件.
export class ComponentOutlet { constructor( private vcRef: ViewContainerRef,private compiler: Compiler,private dataService: DataService ) { } private _createDynamicComponent() { // Some logic to decide which component should be loaded return MyComponent; } ngOnChanges() { this.compiler.compileComponentAsync(this._createDynamicComponent()) .then(factory => { const injector = ReflectiveInjector.fromResolvedProviders([],this.vcRef.parentInjector); this.vcRef.clear(); this.vcRef.createComponent(factory,injector); }); }
问题是MyComponent有一些@Input和Output绑定.可以在这里设置此绑定吗?我怎样才能做到这一点?