@@ -16,7 +16,9 @@ registerElement('DetachedContainer', () => ProxyViewContainer, {
16
16
@Component ( {
17
17
// eslint-disable-next-line @angular-eslint/component-selector
18
18
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>` ,
20
22
} )
21
23
// eslint-disable-next-line @angular-eslint/component-class-suffix
22
24
export class DetachedLoader implements OnDestroy {
@@ -33,7 +35,7 @@ export class DetachedLoader implements OnDestroy {
33
35
return new TemplatePortal ( templateRef , this . vc , context ) ;
34
36
}
35
37
36
- private loadInLocation ( componentType : Type < any > ) : ComponentRef < any > {
38
+ private loadInAppRef ( componentType : Type < any > ) : ComponentRef < any > {
37
39
const factory = this . resolver . resolveComponentFactory ( componentType ) ;
38
40
const componentRef = factory . create ( this . containerRef . injector ) ;
39
41
this . appRef . attachView ( componentRef . hostView ) ;
@@ -52,6 +54,10 @@ export class DetachedLoader implements OnDestroy {
52
54
return componentRef ;
53
55
}
54
56
57
+ private loadInLocation ( componentType : Type < any > ) : ComponentRef < any > {
58
+ return this . vc . createComponent ( componentType ) ;
59
+ }
60
+
55
61
public ngOnDestroy ( ) {
56
62
this . disposeFunctions . forEach ( ( fn ) => fn ( ) ) ;
57
63
}
@@ -65,14 +71,22 @@ export class DetachedLoader implements OnDestroy {
65
71
*/
66
72
public loadComponent ( componentType : Type < any > ) : Promise < ComponentRef < any > > {
67
73
Trace . write ( 'DetachedLoader.loadComponent' , 'detached-loader' ) ;
68
- return Promise . resolve ( this . loadInLocation ( componentType ) ) ;
74
+ return Promise . resolve ( this . loadInAppRef ( componentType ) ) ;
69
75
}
70
76
71
77
/**
72
78
* @deprecated use Portals
73
79
*/
74
80
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' ) ;
76
90
return this . loadInLocation ( componentType ) ;
77
91
}
78
92
@@ -89,4 +103,11 @@ export class DetachedLoader implements OnDestroy {
89
103
} ) ;
90
104
return componentRef ;
91
105
}
106
+
107
+ /**
108
+ * @deprecated use Portals
109
+ */
110
+ public loadWithFactoryInLocation < T > ( factory : ComponentFactory < T > ) : ComponentRef < T > {
111
+ return this . vc . createComponent ( factory ) ;
112
+ }
92
113
}
0 commit comments