angular/components

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

Open

#21,092 建立於 2020年11月19日

在 GitHub 查看
 (3 留言) (0 反應) (0 負責人)TypeScript (24,044 star) (6,650 fork)batch import
P3area: cdk/portaldocsgood first issuehelp wanted

描述

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

貢獻者指南

docs-bug(CdkPortal): @ViewChild() returns undefined when using *cdkPortal instead of <ng-template cdkPortal> · angular/components#21092 | Good First Issue