Skip to the page

Angular core · Trade-off

Standalone components or NgModules

The interviewer asks

Standalone components or NgModules: what's the real difference? You have a 300-component app built on NgModules. Do you migrate, and how?

Then

Follow-ups the interviewer asks next

  1. What did an NgModule do that a standalone component now does itself?
  2. How do you lazy load a standalone component?
  3. Can standalone components and NgModules live together?
  4. What does the standalone migration do, and in what order?
  5. Is there any reason to keep a module?

The answer

What a strong answer covers

  • NgModules set the compilation scope (which components, directives and pipes a template may use) and carried providers. A standalone component lists its own imports, so dependencies are explicit per file, lazy loading is simpler (loadComponent), and tree shaking and @defer work better.
  • Standalone is the default since v19 (no standalone: true needed). NgModules are not deprecated, and the two work together both ways.
  • Providers move to bootstrapApplication(App, appConfig) with provideRouter, provideHttpClient and so on, or to route-level providers.
  • Migration: ng generate @angular/core:standalone in three passes (convert declarations, remove unneeded NgModules, switch to standalone bootstrap), feature by feature with normal releases, then the control-flow and inject() migrations.
  • Keep modules when a library exposes an NgModule API, or when a large stable area has little to gain right now.
  • Watch providers that lived in modules: moving them can change how many instances exist.

The red pen

Common traps

Avoid:"NgModules are removed"; migrating all 300 components in one pull request; forgetting the providers.

Practise this out loud

Say your answer out loud to an AI interviewer that follows up, and get a score for it.

Practise by voice

Practise questions like this out loud

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview