I tried using \"ng destroy component foo\" and it tells me \"The destroy command is not supported by Angular-CLI\"
How do we properly delete components with Angular
This is not supported by Angular CLI and they are in no mood to include it any time soon.
Here is the link to the actual created issue - https://github.com/angular/angular-cli/issues/1776
And a screenshot of the solution from the officials -
destroy
or something similar may come to the CLI, but it is not a primary focus at this time. So you will need to do this manually.
Delete the component directory (assuming you didn't use --flat
) and then remove it from the NgModule
in which it is declared.
If you are unsure of what to do, I suggest you have a "clean" app meaning no current git
changes. Then generate a component and see what is changed in the repo so you can backtrack from there what you will need to do to delete a component.
If you're just experimenting about what you want to generate, you can use the --dry-run
flag to not produce any files on disk, just see the updated file list.