How to Delete Component, Service, Module from Angular

Updated on: September 15, 2019

Currently there is no any specific command to delete Component, Service, Module from your existing Angular App. You will need to delete it manually. Please refer following to know how to delete Component, Service, Modules from your Angular App.

Steps to Delete Component from Angular

  1. Remove import of component from app.module.ts file
  2. Remove component declaration from @NgModule=>declarations section in app.module.ts file
  3. Remove references of Component from other files, to search the references, press "Ctrl+Shift + F" on Visual Studio Code and search for Component Name and remove all references from the search output.
  4. Remove css, html, spec.ts, component.ts file of the component to be deleted from the App.
  5. Save All Changes and then Run the "ng serve" command, to check if it compiles and run properly after deletion of component

Steps to Delete Service from Angular

  1. Remove import of Service from app.module.ts file if any
  2. Remove service provider declaration from app.module.ts file if any 
  3. Remove references of Service from other files, to search the references, press "Ctrl+Shift + F" on Visual Studio Code and search for Service Name and remove all references from the search output.
  4. Remove service.ts and service.spec.ts file of the service to be deleted from the App.
  5. Save All Changes and then Run the "ng build" command, to check if it compiles and run properly after deletion of service

Steps to Delete Module from Angular

  1. Remove import of module from app.module.ts file
  2. Remove module declaration from @NgModule=> imports section in app.module.ts file
  3. Remove references of Module from other files, to search the references, press "Ctrl+Shift + F" on Visual Studio Code and search for Module Name and remove all references from the search output.
  4. Remove module.ts file of the Module to be deleted from the App.
  5. Save All Changes and then Run the "ng serve" command, to check if it compiles and run properly after deletion of component