Angular core · Trade-off
Standalone components or NgModules
Practise this out loud
Say your answer out loud to an AI interviewer that follows up, and get a score for it.
Practise by voiceThe 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
- What did an NgModule do that a standalone component now does itself?
- How do you lazy load a standalone component?
- Can standalone components and NgModules live together?
- What does the standalone migration do, and in what order?
- 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@deferwork better. - Standalone is the default since v19 (no
standalone: trueneeded). NgModules are not deprecated, and the two work together both ways. - Providers move to
bootstrapApplication(App, appConfig)withprovideRouter,provideHttpClientand so on, or to route-levelproviders. - Migration:
ng generate @angular/core:standalonein three passes (convert declarations, remove unneeded NgModules, switch to standalone bootstrap), feature by feature with normal releases, then the control-flow andinject()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 voicePractise 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.