Removing a Page / Component
Last updated
Last updated
Removing a page from the app is pretty straight-forward. You just remove the target folder from the code, and remove the routing associated with it. Also, if this folder or any of its child pages are imported in some other page, you need to remove those as well.
In some cases, there can be nested routing. Let's see an example of removing a nested routed page - Netflix Layout
Go to app-routing.module.ts
file.
Check if the page you want to remove is a direct child of main routing, or is a nested routing child. In our case, Netflix
page is directly routed
Select and delete the route
Also, check if Netflix
page was imported in some other page, and remove that import and its usage as well
You should remove the Netflix
code folder from the project as well, but you can choose to keep it if you think you'll need it in future
Components do not have direct routes in routing files, but they are often imported in many different pages and/or components.
Locate the component folder in the project. Note the export variable name as this will be used for importing the component in other pages / components
In this case, we can see GoogleLoginComponent
as the export variable.
Do a global search of this variable name, and remove the imports from all the files
Components are generally shared via sharable.module.ts
. In that case, you'll have to remove the variable from declarations
and exports
array of the sharable.module.ts
file
Along with the imports, you will have to remove all the features using these variables as well
You are free to delete the component folder or keep it in the project. Once the imports are removed, it won't affect remaining code