Angular › Standalone Components
What is a standalone component in Angular, and how do you create one?
BeginnerAnswer
A standalone component declares its own dependencies, like which other components or directives it uses, directly within itself using an imports array, without needing to be registered inside a separate NgModule. New Angular projects use standalone components by default.
@Component({
selector: 'app-greeting',
standalone: true,
imports: [CommonModule],
template: `<p>Hello there</p>`
})
export class GreetingComponent {}Real-world example A new Angular project built entirely with standalone components skips creating any NgModules at all, keeping each component's own dependencies clearly listed right where they are actually used.