Skip to content

ng g @angular/core:standalone should prefer NgFor instead of NgForOf #49006

@cexbrayat

Description

@cexbrayat

Which @angular/* package(s) are relevant/related to the feature request?

core

Description

ng new standalone-migration --defaults
cd standalone-migration
ng update @angular/core@next @angular/cli@next --force
echo "<div *ngFor="let i of [1, 2]">Hello world</div>" > src/app/app.component.html
ng g @angular/core:standalone --defaults --mode standalone-bootstrap

app.component.ts gets migrated to:

import { Component } from '@angular/core';
import { NgForOf } from '@angular/common';

@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.css'],
    standalone: true,
    imports: [NgForOf]
})
export class AppComponent {
  title = 'standalone-migration';
}

Proposed solution

The recently introduced alias NgFor should be used instead of NgForOf

Alternatives considered

It can be replaced manually

Metadata

Metadata

Assignees

Labels

area: migrationsIssues related to `ng update`/`ng generate` migrationscross-cutting: standaloneIssues related to the NgModule-less world

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions