Standalone components can be used directly without needing to be declared inside an NgModule. This simplifies the app structure and reduces boilerplate.
import { Component, inject } from '@angular/core'; import { DataService } from './data.service'; @Component({ selector: 'app-standalone', standalone: true, template: `<p>{{ data }}</p>` }) export class StandaloneComponent { private dataService = inject(DataService); data = this.dataService.getData(); }
If a service is not provided in the injector tree, Angular throws an error when inject() is called because it cannot find the dependency.
Standalone components are still Angular components and support all lifecycle hooks just like traditional components.
The standalone property must be set to true in the @Component decorator. The template can be inline or external. Option B correctly sets standalone: true and uses an inline template.
The NG0303 error indicates that the 'child-component' is recognized as a component (so properly imported), but it does not have an @Input() property named 'someInput' defined.