angular/components

docs-bug(CdkPortal): @ViewChild() returns undefined when using *cdkPortal instead of <ng-template cdkPortal>

已关闭

#21,092 创建于 2020年11月19日

 (3 条评论) (0 个反应) (0 位负责人)TypeScript (6,650 个派生)batch import
P3area: cdk/portaldocsgood first issuehelp wanted

仓库指标

星标
 (24,044 个星标)
PR 合并指标
 (平均合并 3天 12小时) (30 天内合并 98 个 PR)

描述

The official doc says:

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

贡献者指南