-
Notifications
You must be signed in to change notification settings - Fork 24.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conditionals and content projection #54840
Comments
I'd like to add to this, I'm not sure however, if related or not. Some selectors do not work if the content itself is generated (e.g. with
By using this component, an element with a
However, if generated dynamically, then nothing is projected, nothing is shown:
Please note: if I use a component attribute name as a selector (e.g. Edit: Edit 2: |
@csisy-btw could you please open a separate issue for your use-case, ideally with a minimal reproduction scenario in a stackblitz? Otherwise we might miss this one. Thnx! |
This commit changes the way we use containers to insert conditional content. Previously if and switch conditional would always use the first content as the insertion container. This strategy interfered with content projection that projects entire containers - as the consequence content for _all_ cases would end up in slot matched by the first container. This could be very surprising as desicribed in angular#54840 After the change each conditional content is projected into its own container. This means that content projection can match more than one container and result in correct display. Fixes angular#54840
This commit changes the way we use containers to insert conditional content. Previously if and switch conditional would always use the first content as the insertion container. This strategy interfered with content projection that projects entire containers - as the consequence content for _all_ cases would end up in slot matched by the first container. This could be very surprising as desicribed in angular#54840 After the change each conditional content is projected into its own container. This means that content projection can match more than one container and result in correct display. Fixes angular#54840
PR: #54879 |
This commit changes the way we use containers to insert conditional content. Previously if and switch conditional would always use the first content as the insertion container. This strategy interfered with content projection that projects entire containers - as the consequence content for _all_ cases would end up in slot matched by the first container. This could be very surprising as desicribed in angular#54840 After the change each conditional content is projected into its own container. This means that content projection can match more than one container and result in correct display. Fixes angular#54840
…ngular#54921) This commit changes the way we use containers to insert conditional content. Previously if and switch conditional would always use the first content as the insertion container. This strategy interfered with content projection that projects entire containers - as the consequence content for _all_ cases would end up in slot matched by the first container. This could be very surprising as desicribed in angular#54840 After the change each conditional content is projected into its own container. This means that content projection can match more than one container and result in correct display. Fixes angular#54840 PR Close angular#54921
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
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@if
statement with theelse
branch: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@if
container and container capturing thesome-content
as 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
The text was updated successfully, but these errors were encountered: