Open
Description
The official doc says:
The content of this template is captured by the portal.
The content of this template is captured by the portal.
A component can use @ViewChild or @ViewChildren to get a reference to a CdkPortal.
However, @ViewChild('theElementRef')
binds to undefined
when I use the *cdkPortal
notation,
while it works when I use <ng-template cdkPortal>
I suspect *cdkPortal
makes the element to leave the page before afterViewInit()
.
Maybe the documentation should encourage using the <ng-template>
form instead.
Affected documentation page: https://material.angular.io/cdk/portal/overview#portals-in-practice