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
- Remove import of component from app.module.ts file
- Remove component declaration from @NgModule=>declarations section in app.module.ts file
- 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.
- Remove css, html, spec.ts, component.ts file of the component to be deleted from the App.
- 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
- Remove import of Service from app.module.ts file if any
- Remove service provider declaration from app.module.ts file if any
- 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.
- Remove service.ts and service.spec.ts file of the service to be deleted from the App.
- 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
- Remove import of module from app.module.ts file
- Remove module declaration from @NgModule=> imports section in app.module.ts file
- 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.
- Remove module.ts file of the Module to be deleted from the App.
- Save All Changes and then Run the "ng serve" command, to check if it compiles and run properly after deletion of component