angular/components

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

Open

#21.092 geöffnet am 19. Nov. 2020

Auf GitHub ansehen
 (3 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)TypeScript (24.044 Stars) (6.650 Forks)batch import
P3area: cdk/portaldocsgood first issuehelp wanted

Beschreibung

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

Contributor Guide