Interview questions

Standalone components vs NgModules

Modern architecture question with migration nuance.

intermediate Experienced

What is tested: understanding of Angular’s shift away from NgModules. Standalone components declare their own imports, removing the declarations/exports bookkeeping and making dependencies explicit at the component.

NgModules are a shared supply cupboard the whole floor must stock and unlock; standalone components each carry a labelled toolkit with exactly what they use.

Key concepts

1
Benefits: simpler mental model, better tree-shaking, component-level lazy loading with loadComponent, and easier testing. Providers move to bootstrapApplication and providdeIn: 'root' or route-level providers.
loadComponentbootstrapApplicationproviddeIn: 'root'providers
2
Migration nuance: standalone and NgModule code interoperate — you can import standalone components into existing modules and adopt incrementally, which is the realistic answer for a large codebase.
Migration nuance:
3
Follow-up: "where do global providers live without AppModule?" — bootstrapApplication(App, { providers: [...] }) and provideRouter, provideHttpClient functions.
Follow-up:bootstrapApplication(App, { providers: [...] })provideRouterprovideHttpClient