Standalone Components — Angular Technical Interview Questions & Answers
Standalone Components
Standalone Components
- Standalone: standalone: true, imports: [CommonModule, RouterLink] on the component. No NgModule required. New Angular apps bootstrap this way.
- You still must import what the template uses. Forget CommonModule → *ngIf unknown. Forget RouterLink → routerLink isn’t a property.
- Trap: mixing old NgModule declarations with standalone without importing the standalone component where it’s used.
Technical Interview Tip: standalone + imports array. Why CommonModule.
Code Examples for Standalone Components
Standalone Components — working example
import { Component } from "@angular/core";
@Component({
selector: "app-hello",
template: `<h1>Hello {{ name }}</h1>`,
})
export class HelloComponent {
name = "Angular";
}Standalone Components — @Component ties a class to a selector + template.
How to Explain Standalone Components to an Interviewer
What does standalone: true change?
No NgModule imports[] on the component