Full answer
A migration is a project, not a command. A safe plan:
- Get the tests and the build green first. Without tests a migration is guesswork.
- Update the framework.
ng update @angular/core @angular/climoves one major version at a time. Read the update guide for each version, fix deprecations, and keep third-party libraries compatible. - Standalone.
ng generate @angular/core:standalonehas three modes, run in order: convert declarations to standalone, remove unnecessary NgModules, and switch the bootstrap tobootstrapApplication. Commit after each mode. Libraries that still export NgModules can be imported into standalone components. - Control flow.
ng generate @angular/core:control-flowrewrites*ngIf,*ngFor, and*ngSwitchto@if,@for, and@switch. Review the generatedtrackexpressions. Thenng generate @angular/core:cleanup-unused-importsremoves imports that are no longer needed. - Dependency injection style.
ng generate @angular/core:injectconverts constructor parameters toinject(). - Routing.
ng generate @angular/core:route-lazy-loadingturns eager component routes intoloadComponent. Convert class guards, resolvers, and interceptors to functions, andHttpClientModuletoprovideHttpClient(). - Signals (optional and gradual).
signal-input-migration,output-migration, andsignal-queries-migrationconvert@Input,@Output, and@ViewChild. Start with leaf components. - Performance steps after that: OnPush, and then zoneless once the app is ready.
Keep a rule: new code uses the modern style, old code is converted when touched, or in planned batches. This avoids a big-bang rewrite. Review each migration diff, since schematics can produce code that compiles but needs manual tidying.
What does not need migration: NgModules still work and are still supported, and *ngIf still compiles in Angular 20 (it is deprecated). The team should decide by value: converting code that nobody changes has a low return.
typescript
// file: legacy/list.module.ts
import { CommonModule } from '@angular/common';
import { Component, Input, NgModule } from '@angular/core';
// LEGACY style: NgModule, decorator input, and structural directives.
@Component({
selector: 'app-legacy-list',
standalone: false,
template: `
<ul *ngIf="items.length > 0; else empty">
<li *ngFor="let item of items; trackBy: trackById">{{ item.name }}</li>
</ul>
<ng-template #empty><p>No items</p></ng-template>
`,
})
export class LegacyListComponent {
@Input() items: { id: number; name: string }[] = [];
trackById(_index: number, item: { id: number }): number {
return item.id;
}
}
@NgModule({
declarations: [LegacyListComponent],
imports: [CommonModule],
exports: [LegacyListComponent],
})
export class LegacyListModule {}
// file: modern/list.component.ts
import { Component, input } from '@angular/core';
// MODERN style: standalone, signal input, and built-in control flow.
@Component({
selector: 'app-list',
template: `
@if (items().length > 0) {
<ul>
@for (item of items(); track item.id) {
<li>{{ item.name }}</li>
}
</ul>
} @else {
<p>No items</p>
}
`,
})
export class ListComponent {
readonly items = input<{ id: number; name: string }[]>([]);
}
// file: modern/page.component.ts
import { Component } from '@angular/core';
import { LegacyListModule } from '../legacy/list.module';
import { ListComponent } from './list.component';
// Both styles can live in the same page during a gradual migration.
@Component({
selector: 'app-page',
imports: [LegacyListModule, ListComponent],
template: `
<app-legacy-list [items]="data" />
<app-list [items]="data" />
`,
})
export class PageComponent {
data = [{ id: 1, name: 'Asha' }];
}Angular 20.3, type-checked. The file shows one list component in the old style (legacy, kept compiling on purpose) and the same screen in the modern style.
Key points
- Update with `ng update`, one major version at a time, with a green test suite.
- Run schematics in order: standalone, control flow, inject, route lazy loading, signal APIs.
- Commit per step and migrate by feature. Old and new can coexist.
- Convert class-based guards, resolvers, and interceptors to functions.
Common mistakes
- Updating several major versions at once and then being unable to find what broke.
- Running every schematic in one commit, so the diff cannot be reviewed.
- Rewriting stable, untouched modules for style only.
Follow-ups
- How would you keep two teams productive while the migration runs?
- Which migration gives the highest return first?
- How do you handle a library that does not support standalone?
Tips
- Give the order and the reason for it. It shows you have done or planned it.
- Mention tests first, then small commits.
- Say that you would not migrate everything at once and explain how you decide.
Evaluation rubric
- Gives a safe, ordered plan with real schematic names.
- Understands coexistence of styles.
- Considers risk and cost.