-
Notifications
You must be signed in to change notification settings - Fork 27.1k
control-flow migration doesnt migrate code properly with *ngIf else /ng-template #52513
Copy link
Copy link
Closed
Closed
Copy link
Labels
area: migrationsIssues related to `ng update`/`ng generate` migrationsIssues related to `ng update`/`ng generate` migrationscore: control flowIssues related to the built-in control flow (@if, @for, @switch)Issues related to the built-in control flow (@if, @for, @switch)
Milestone
Description
Which @angular/* package(s) are the source of the bug?
core
Is this a regression?
Yes
Description
For example for the code like the one mentioned below:
<div *ngIf="pageNotFound && !isLoading; else pageContents" class="mat-card">
<h1>Page Not Found</h1>
<p>Sorry! The page you are looking for does't not exist, either it has been deactivate or removed.</p>
</p>
</div>
<ng-template #pageContents>
</ng-template>
The generated output is :
@if (pageNotFound && !isLoading) {
<div class="mat-card">
<h1>Company Profile Not Found</h1>
<p>Sorry! The profile you are looking for does't not exist, either it has been deactivate or removed.</p>
</div>
} @else {
The code which was inside the ng-template is placed here (without any changes).
}
<ng-template #pageContents>
The code with the new control flow remains here inside ng-template. It should have been placed inside the above else statement, and this ng-template block should have been removed.
</ng-template>
Please provide a link to a minimal reproduction of the bug
For this I can add you to a private repo
Please provide the exception or error you saw
No exception, is show because generated code is till valid. But migrations is not performed properly.
Please provide the environment you discovered this bug in (run ng version)
17.0.0-rc.2
Anything else?
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area: migrationsIssues related to `ng update`/`ng generate` migrationsIssues related to `ng update`/`ng generate` migrationscore: control flowIssues related to the built-in control flow (@if, @for, @switch)Issues related to the built-in control flow (@if, @for, @switch)