Importing Dependencies Directly
Add imports to a component instead of a module.
Importing Dependencies Directly
A standalone component declares what it uses in its own imports array. This replaces the NgModule declarations/imports split.
The imports Array
Add other standalone components, directives, and pipes to the imports array of the @Component decorator.
import { Component } from '@angular/core';
import { ChildComponent } from './child.component';
@Component({
selector: 'app-parent',
imports: [ChildComponent],
template: '<app-child></app-child>'
})
export class ParentComponent {}All lessons in this course
- Why Standalone Components
- Creating Standalone Components
- Importing Dependencies Directly
- Bootstrapping a Standalone App