Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
docs-bug(CdkPortal): @ViewChild() returns undefined when using *cdkPortal instead of <ng-template cdkPortal> #21092
Comments
|
Hi,
Or if you want to access the TemplateRef and not the CdkPortal:
This works with both cdkPortal notation (tested in v11) |


The official doc says:
However,
@ViewChild('theElementRef')binds toundefinedwhen I use the*cdkPortalnotation,while it works when I use
<ng-template cdkPortal>I suspect
*cdkPortalmakes the element to leave the page beforeafterViewInit().Maybe the documentation should encourage using the
<ng-template>form instead.Affected documentation page: https://material.angular.io/cdk/portal/overview#portals-in-practice