fix(compiler-cli): mention ngProjectAs in content projection control flow error#68652
Open
NoeliaBentancor wants to merge 2 commits into
Open
Conversation
…flow error Update the diagnostic message for NG8011 to explicitly suggest using `ngProjectAs` on an `<ng-container>` when content inside a control flow block fails to project into a named slot. Also clarifies when to use option 1 (ngProjectAs, for single-slot targeting) vs option 2 (splitting blocks, for multi-slot scenarios). Fixes angular#59398
This comment was marked as outdated.
This comment was marked as outdated.
b9a4f34 to
988a7a2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #59398
PR Checklist
PR Type
What is the current behavior?
The diagnostic error NG8011 (
controlFlowPreventingContentProjection) suggests wrapping content in an<ng-container/>but does not mentionngProjectAs, which is the key attribute needed to make the workaround actually work for named slots.Users following the existing suggestion have no way to know they need
ngProjectAs="[selector]"to target a specific slot, leading to confusion (as reported in the issue).Additionally, the message does not clarify when to use the wrapping approach vs. splitting into multiple blocks, which are solutions for different scenarios (single-slot vs. multi-slot targeting).
What is the new behavior?
Option 1 of the diagnostic now explicitly shows
<ng-container ngProjectAs="[selector]">with the actual slot selector interpolated, and explains this is the right approach when all nodes target the same slot.Option 2 now clarifies it is needed when nodes target different slots.
Example
Before:
After: