-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Control flow - template used in multiple else clauses #52854
Copy link
Copy link
Closed
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 relevant/related to the feature request?
No response
Description
When the same template is used in multiple*ngIf else clauses then te code is incorectly migrated
<div *ngIf="hasPermission; else noPermission">presentation</div>
<div *ngIf="someOtherPermission; else noPermission">presentation</div>
<ng-template #noPermission>
<div>Imagine more than just some text</div>
</ng-template>@if (hasPermission) {
<div>presentation</div>
} @else {
<div>Imagine more than just some text</div>
}
@if (someOtherPermission) {
<div>presentation</div>
} @else {
#noPermission|
}
<ng-template #noPermission>
<div>Imagine more than just some text</div>
</ng-template>Proposed solution
- Use
<ng-container *ngTemplateOutlet="noPermission">and leave<ng-template #noPermission>
Alternatives considered
- Just duplicate template code and remove template
Not sure which is better so mayby allow for interactive migration and let user decide? Or at least flag for user preference.
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)