How To Delete A Component In Angular

Deleting components in Angular

Steps to delete a component in Angular

  1. Remove the import line reference from Angular app.module.ts file.
  2. Remove the component declaration from @NgModule declaration array in app.module.ts file
  3. And then manually delete the component folder from Angular project.
  4. Finally Delete all the references of component manually from the Angular project.

In Angular CLI,there is no command available to delete a component created by Angular CLI as of now.

There is no ng delete component command as part of Angular CLI.

If you want to know what will happen at the time of component creation. you can try --dry--run flag

ng generate component test --dry--run
CREATE src/app/test/test.component.html (23 bytes)
CREATE src/app/test/test.component.spec.ts (614 bytes)
CREATE src/app/test/test.component.ts (261 bytes)
CREATE src/app/test/test.component.css (0 bytes)
UPDATE src/app/app.module.ts (914 bytes)

NOTE: The "dryRun" flag means no changes were made.

No changes being made to the project.


Arunkumar Gudelli

Liked this post? Subscribe