Standalone

Update Angular CLI and Angular Core

ng update @angular/cli @angular/core
ng g c parent --standalone

Components, directives, and pipes can now be marked as standalone: true. Angular classes marked as standalone do not need to be declared in an NgModule (the Angular compiler will report an error if you try).

Standalone components specify their dependencies directly instead of getting them through NgModules.

import { Component } from '@angular/core';

@Component({
  selector: 'app-input-parent-to-child',
  standalone: true,
  templateUrl: './input-parent-to-child.component.html',
  styleUrls: ['./input-parent-to-child.component.scss'],
})
export class InputParentToChildComponent {}

app.module.ts

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { InputParentToChildComponent } from './components/input-parent-to-child/input-parent-to-child.component';

@NgModule({
  declarations: [AppComponent],
  imports: [BrowserModule, AppRoutingModule, InputParentToChildComponent],
  providers: [],
  bootstrap: [AppComponent],
})
export class AppModule {}
Was this page helpful?