Repository navigation
Closed
Labels
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: coreIssues related to the framework runtimebugcore: content projectioncore: control flowIssues related to the built-in control flow (@if, @for, @switch)state: has PR
Milestone
Description
Which @angular/* package(s) are the source of the bug?
core
Is this a regression?
No
Description
When I try to display some HTML within an @empty block is not rendering anything whereas if I am using a @if approach is working fine.
Bellow snippet belongs to a nested HTML propagated using Angular projections (the main attribute is a projection area)
<plc-box main *ngrxLet="games$ as games">
@for (game of games; track game._id) {
<plc-game-row main [game]="game"></plc-game-row>
} @empty { <!-- <=== This line FAILS-->
<!-- } @if(games.length === 0) { --> <!-- <=== This line WORKS-->
<ng-container main>
<plc-icon [name]="'landscape'" ></plc-icon>
<plc-label class="plc-search-game__no-record-label">
{{ 'pages.search-game.no-results' | translate }}
</plc-label>
</ng-container>
}
</plc-box>Same code outside of a propagation based component works fine (e.g. inside a regular <div></div>)
Please provide a link to a minimal reproduction of the bug
Minimal reproduction in StackBlitz
Please provide the exception or error you saw
I see a blank spot where a HTML should be displayed instead
Please provide the environment you discovered this bug in (run ng version)
Angular CLI: 17.0.7
Node: 18.18.2
Package Manager: npm 9.8.1
OS: win32 x64
Angular: 17.0.7
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1700.7
@angular-devkit/build-angular 17.0.7
@angular-devkit/core 17.0.7
@angular-devkit/schematics 17.0.7
@angular/cdk 16.0.1
@angular/material 16.0.1
@schematics/angular 17.0.7
ng-packagr 17.0.2
rxjs 7.8.1
typescript 5.2.2
zone.js 0.14.2
Anything else?
No response
Metadata
Metadata
Assignees
Labels
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: coreIssues related to the framework runtimebugcore: content projectioncore: control flowIssues related to the built-in control flow (@if, @for, @switch)state: has PR
Activity
JoostK commentedon Dec 14, 2023
Please provide a minimum, runnable reproduction.
WarGreyGon commentedon Dec 14, 2023
@JoostK updated description with reproduction link 🙂
JoostK commentedon Dec 14, 2023
Thanks, that has been very helpful. It seems like the empty template is not considered for projection, as was done for the primary blocks of
ifandforin #52414.crisbeto commentedon Dec 14, 2023
This is currently "working as intended". The problem is that we use the main
@forblock as the insertion point both for the loop contents and the@emptycontents.pkozlowski-opensource commentedon Dec 18, 2023
There was a refactoring at some point with which the main loop content and the empty blocks have their separate insertion containers. Capturing a tag name based on the empty block content (as we do for if, for etc.) should do the trick for the empty block as well.
fix(compiler): project empty block root node
angular-automatic-lock-bot commentedon Jan 19, 2024
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.
fix(compiler): project empty block root node (angular#53620)
fix(compiler): project empty block root node (angular#53620)
fix(compiler): project empty block root node (angular#53620)