【发布时间】:2016-08-29 15:52:36
【问题描述】:
在我的 ModalComponent 中,我有以下内容:
_eventEmitterService.modal.subscribe(stream=>{
var component = ModalTemplateComponent;
stream.subscribe(msg=>{
this.componentRef.dispose();
this.componentRef = null;
});
this._dcl.loadIntoLocation(component,_elementRef, 'modal').then((componentRef)=>{
this.componentRef = componentRef;
});
})
在我更新到 Angular 17 之前效果很好。
在更新日志中,我读到:
DynamicComponentLoader.loadIntoLocation 已被删除。采用 @ViewChild('myVar', read: ViewContainerRef) 来获取一个 ViewContainerRef 在具有变量 myVar 的元素上。然后打电话 DynamicComponentLoader.loadNextToLocation
所以,据我所知,我需要补充:
@ViewChild('selector-modal') child:ModalComponent;
到持有 ModalComponent 的组件。
但是,我不太确定应该如何在 ModalComponent 中加载我的新组件:
this._dcl.loadIntoLocation(component,_elementRef, 'modal').then((componentRef)=>{
this.componentRef = componentRef;
});
在过去的 angular-16 版本中 this 的等价物是什么?
【问题讨论】:
标签: angular