angular/components

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

クローズ

#21,092 opened on 2020/11/19

 (3 件のコメント) (0 件のリアクション) (0 人の担当者)TypeScript (6,650 件のフォーク)batch import
P3area: cdk/portaldocsgood first issuehelp wanted

Repository metrics

Stars
 (24,044 個のスター)
PR merge metrics
 (平均マージ 3d 12h) (30d で 98 merged PRs)

説明

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

コントリビューターガイド