Skip to content

control flow: weird behavior of ng-template migration #52518

@zip-fa

Description

@zip-fa

Which @angular/* package(s) are the source of the bug?

core

Is this a regression?

No

Description

Hi. Migration of *ngFor block inside ng-template works weird.

Initial template:

<ng-container *ngIf="cond; else testTpl">
bla bla
</ng-container>

<ng-template #testTpl>
  <div class="test"
      *ngFor="let item of items"
    ></div>
</ng-template>

Result:

@if (cond) {
bla bla
} @else {
<div class="test"
  *ngFor="let item of items" <--- why this was not migrated
  ></div>
}

<ng-template #testTpl>
  @for (item of items; track item) { <--- while this was
  <div class="test"></div>
}
</ng-template>

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

No response

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 17.0.0-rc.3
Node: 18.18.1
Package Manager: npm 9.8.1
OS: win32 x64

Angular: 17.0.0-rc.2
... animations, cdk, common, compiler, compiler-cli, core, forms
... localize, material, platform-browser
... platform-browser-dynamic, platform-server, router
... service-worker

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1700.0-rc.3
@angular-devkit/build-angular   17.0.0-rc.3
@angular-devkit/core            17.0.0-rc.3
@angular-devkit/schematics      17.0.0-rc.3
@angular/cli                    17.0.0-rc.3
@angular/ssr                    17.0.0-rc.3
@schematics/angular             17.0.0-rc.3
rxjs                            7.8.1
typescript                      5.2.2
zone.js                         0.14.0

Anything else?

No response

Metadata

Metadata

Assignees

Labels

area: migrationsIssues related to `ng update`/`ng generate` migrationscore: control flowIssues related to the built-in control flow (@if, @for, @switch)

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions