Components and templates · core
Standalone components and NgModules
A standalone component lists its own imports, so each file shows what it uses. NgModules are the older way and still appear in old code and in interviews.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- An NgModule set the compilation scope: which components, directives and pipes a template may use. It also carried providers.
- A standalone component has its own
importsarray. Its dependencies are visible in one file. - Standalone components are the default since v19 (facts.md). In new code you do not write
standalone: true. - Lazy loading is simpler with standalone:
loadComponentloads one component without a module. - Tree shaking and
@deferwork better when dependencies are explicit per component. - Standalone and NgModule code can live together. A standalone component can import an NgModule, and an NgModule can import a standalone component.
- Say clearly which is older: NgModules are the old style. Modern apps start with
bootstrapApplicationandprovideRouter, notAppModule.
The red pen
Common traps: mistake → fix
Mistake: NgModules are removed from Angular
Fix: they still work and old apps use them; new code just does not need them.
Mistake: A standalone component needs a module to be used in a template
Fix: it goes into the
importsof the component that uses it.
Easy to hard
Questions interviewers ask, easy to hard
- What is the difference between a standalone component and one declared in an NgModule?
- Where do you register a pipe that a standalone component uses?
- How does lazy loading change when you drop NgModules?
- Your company has a big NgModule app. How would you move it to standalone?
Practise
Practise with these questions
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.