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

貢獻者指南