Angular 9 isssue with dynamic component load

Deadly 提交于 2021-02-11 16:56:56

问题


Dynamic components were loading absolutely fine in Angular 8. Once a component is loaded, Detach and Interest of components was also working fine. I am using ng-three-template.

    loadComponent(componentID: number, component: any) {
        this.viewContainerRef.detach();

        if( this.componentFactory[componentID] == undefined ) {

          this.componentFactory[componentID] = this.componentFactoryResolver.resolveComponentFactory( component );
          this.componentRef[componentID] = this.viewContainerRef.createComponent( this.componentFactory[componentID] );

        }
        else {
          this.viewContainerRef.insert( this.componentRef[componentID]._viewRef );
        }

  }

When I upgraded to Angular 9, component does get load, then detach, but don't Insert back again

Angular 8 console:

Angular 9 console:

Please help me with this issue, Thanks

来源:https://stackoverflow.com/questions/61809302/angular-9-isssue-with-dynamic-component-load

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!