-
Notifications
You must be signed in to change notification settings - Fork 29.2k
Conditionals and content projection #54840
Copy link
Copy link
Closed
Labels
area: coreIssues related to the framework runtimeIssues related to the framework runtimecore: content projectioncore: control flowIssues related to the built-in control flow (@if, @for, @switch)Issues related to the built-in control flow (@if, @for, @switch)state: has PR
Milestone
Description
Activity
Metadata
Metadata
Assignees
Labels
area: coreIssues related to the framework runtimeIssues related to the framework runtimecore: content projectioncore: control flowIssues related to the built-in control flow (@if, @for, @switch)Issues related to the built-in control flow (@if, @for, @switch)state: has PR
Which @angular/* package(s) are the source of the bug?
core
Is this a regression?
No
Description
There is a surprising interaction between our static (creation time) content projection system and the new control flow (although this is not specific to the new control flow - the same can be observed with
ngIf).To illustrate the surprising scenario let's consider a component with content projection with a selector (
<ng-content select="some-content">) and content to project wrapped in the control flow@ifstatement with theelsebranch:https://stackblitz.com/edit/stackblitz-starters-57dynz?file=src%2Fmain.ts
As surprising as it may be, the
I'm not the content queried for, don't project me!text node will be taken as content to project (!). This is consistent with the existing implementation which will project the whole@ifcontainer and container capturing thesome-contentas a tag name of a root node.While we can't fix all issues with the content projection, we could remedy this one by
Please provide a link to a minimal reproduction of the bug
https://stackblitz.com/edit/stackblitz-starters-57dynz?file=src%2Fmain.ts
Please provide the exception or error you saw
No response
Please provide the environment you discovered this bug in (run
ng version)No response
Anything else?
No response