@@ -52,6 +52,9 @@ export class CdkPortalOutlet extends BasePortalOutlet implements OnInit, OnDestr
52
52
/** Whether the portal component is initialized. */
53
53
private _isInitialized = false ;
54
54
55
+ /** Reference to the currently-attached component/view ref. */
56
+ private _result : ComponentRef < any > | EmbeddedViewRef < any > | null ;
57
+
55
58
constructor (
56
59
private _componentFactoryResolver : ComponentFactoryResolver ,
57
60
private _viewContainerRef : ViewContainerRef ) {
@@ -93,13 +96,19 @@ export class CdkPortalOutlet extends BasePortalOutlet implements OnInit, OnDestr
93
96
this . _attachedPortal = portal ;
94
97
}
95
98
99
+ /** Component or view reference that is attached to the portal. */
100
+ get result ( ) : ComponentRef < any > | EmbeddedViewRef < any > | null {
101
+ return this . _result ;
102
+ }
103
+
96
104
ngOnInit ( ) {
97
105
this . _isInitialized = true ;
98
106
}
99
107
100
108
ngOnDestroy ( ) {
101
109
super . dispose ( ) ;
102
110
this . _attachedPortal = null ;
111
+ this . _result = null ;
103
112
}
104
113
105
114
/**
@@ -125,6 +134,7 @@ export class CdkPortalOutlet extends BasePortalOutlet implements OnInit, OnDestr
125
134
126
135
super . setDisposeFn ( ( ) => ref . destroy ( ) ) ;
127
136
this . _attachedPortal = portal ;
137
+ this . _result = ref ;
128
138
129
139
return ref ;
130
140
}
@@ -140,6 +150,7 @@ export class CdkPortalOutlet extends BasePortalOutlet implements OnInit, OnDestr
140
150
super . setDisposeFn ( ( ) => this . _viewContainerRef . clear ( ) ) ;
141
151
142
152
this . _attachedPortal = portal ;
153
+ this . _result = viewRef ;
143
154
144
155
return viewRef ;
145
156
}
0 commit comments