0 votes
in Angular by
How to create a standalone component uing CLI command?

1 Answer

0 votes
by

Generate standalone component using CLI command as shown below

ng generate component component-name --standalone

On running the command standalone component is created. Here is the list of file created.

  1. component-name.component.ts
  2. component-name.component.css
  3. component-name.component.spec
  4. component-name.component.html

Next need to update app.module.ts as shown below.

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { ComponentNameComponent } from './component-name/component-name.component';

@NgModule({
  imports: [
    BrowserModule,
    ComponentNameComponent
  ],
  declarations: [AppComponent],
  bootstrap: [AppComponent],
})
export class AppModule {}
...