@@ -16,7 +16,9 @@ registerElement('DetachedContainer', () => ProxyViewContainer, {
1616@Component ( {
1717 // eslint-disable-next-line @angular-eslint/component-selector
1818 selector : 'DetachedContainer' ,
19- template : `<Placeholder #loader></Placeholder><ng-container #vc></ng-container><ng-content></ng-content>` ,
19+ template : `<Placeholder #loader></Placeholder>
20+ <ng-container #vc></ng-container>
21+ <ng-content></ng-content>` ,
2022} )
2123// eslint-disable-next-line @angular-eslint/component-class-suffix
2224export class DetachedLoader implements OnDestroy {
@@ -33,7 +35,7 @@ export class DetachedLoader implements OnDestroy {
3335 return new TemplatePortal ( templateRef , this . vc , context ) ;
3436 }
3537
36- private loadInLocation ( componentType : Type < any > ) : ComponentRef < any > {
38+ private loadInAppRef ( componentType : Type < any > ) : ComponentRef < any > {
3739 const factory = this . resolver . resolveComponentFactory ( componentType ) ;
3840 const componentRef = factory . create ( this . containerRef . injector ) ;
3941 this . appRef . attachView ( componentRef . hostView ) ;
@@ -52,6 +54,10 @@ export class DetachedLoader implements OnDestroy {
5254 return componentRef ;
5355 }
5456
57+ private loadInLocation ( componentType : Type < any > ) : ComponentRef < any > {
58+ return this . vc . createComponent ( componentType ) ;
59+ }
60+
5561 public ngOnDestroy ( ) {
5662 this . disposeFunctions . forEach ( ( fn ) => fn ( ) ) ;
5763 }
@@ -65,14 +71,22 @@ export class DetachedLoader implements OnDestroy {
6571 */
6672 public loadComponent ( componentType : Type < any > ) : Promise < ComponentRef < any > > {
6773 Trace . write ( 'DetachedLoader.loadComponent' , 'detached-loader' ) ;
68- return Promise . resolve ( this . loadInLocation ( componentType ) ) ;
74+ return Promise . resolve ( this . loadInAppRef ( componentType ) ) ;
6975 }
7076
7177 /**
7278 * @deprecated use Portals
7379 */
7480 public loadComponentSync ( componentType : Type < any > ) : ComponentRef < any > {
75- Trace . write ( 'DetachedLoader.loadComponent' , 'detached-loader' ) ;
81+ Trace . write ( 'DetachedLoader.loadComponentSync' , 'detached-loader' ) ;
82+ return this . loadInAppRef ( componentType ) ;
83+ }
84+
85+ /**
86+ * @deprecated use Portals
87+ */
88+ public loadComponentInLocation ( componentType : Type < any > ) : ComponentRef < any > {
89+ Trace . write ( 'DetachedLoader.loadComponentInLocation' , 'detached-loader' ) ;
7690 return this . loadInLocation ( componentType ) ;
7791 }
7892
@@ -89,4 +103,11 @@ export class DetachedLoader implements OnDestroy {
89103 } ) ;
90104 return componentRef ;
91105 }
106+
107+ /**
108+ * @deprecated use Portals
109+ */
110+ public loadWithFactoryInLocation < T > ( factory : ComponentFactory < T > ) : ComponentRef < T > {
111+ return this . vc . createComponent ( factory ) ;
112+ }
92113}
0 commit comments