ile yükle Bileşenlerimden bazılarını bu kod parçasıyla dinamik olarak yüklüyorum.Köşeli 2: Bileşeni dinamik olarak @ Giriş ve @ Çıkış
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, 0, injector);
});
}
sorun MyComponent
bazı @Input
ve Output
bağlamaları olmasıdır. Bu bağlamaları burada ayarlamak mümkün mü? Bunu nasıl başarabilirim?
gibi yapmak + 'şimdi .compileComponentAsync' var .. burada bir seçenek http://stackoverflow.com/q/38888008/1679310 kontrol edebilirsiniz bindings girişi ile) * –
@ RadimKöhler 'compileComponentAsync 'RC6'da kaldırıldı. RC6 + ile şimdi "compileModuleAndAllComponentsAsync" – yurzui
@yurzui, doğru .. bu demek istediğim –