Creating Standalone Components
Declare components with the standalone flag.
Creating a Standalone Component
A standalone component is just a class decorated with @Component that is marked standalone. In Angular v19+ this is the default, so you often do not even write the flag.
The standalone Flag
Historically you set standalone: true in the decorator. In v19 and later, components are standalone by default, so the flag is optional.
import { Component } from '@angular/core';
@Component({
selector: 'app-greeting',
standalone: true, // optional in v19+
template: '<h1>Welcome</h1>'
})
export class GreetingComponent {}All lessons in this course
- Why Standalone Components
- Creating Standalone Components
- Importing Dependencies Directly
- Bootstrapping a Standalone App