angular/components

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

Fermée

#21 092 ouverte le 19 nov. 2020

 (3 commentaires) (0 réaction) (0 personne assignée)TypeScript (6 650 forks)batch import
P3area: cdk/portaldocsgood first issuehelp wanted

Métriques du dépôt

Stars
 (24 044 étoiles)
Métriques de merge PR
 (Merge moyen 3j 12h) (98 PRs mergées en 30 j)

Description

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

Guide contributeur