使用CLI删除组件的最佳方法是什么 [英] What is the best way to delete a component with CLI

查看:105
本文介绍了使用CLI删除组件的最佳方法是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用"ng destroy component foo",它告诉我"Angular-CLI不支持destroy命令"

I tried using "ng destroy component foo" and it tells me "The destroy command is not supported by Angular-CLI"

如何使用Angular CLI正确删除组件?

How do we properly delete components with Angular CLI?

推荐答案

destroy或类似的内容可能会出现在CLI上,但目前并不是主要关注点.因此,您将需要手动执行此操作.

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.

删除组件目录(假设您未使用--flat),然后将其从声明它的NgModule中删除.

Delete the component directory (assuming you didn't use --flat) and then remove it from the NgModule in which it is declared.

如果您不确定该怎么做,建议您使用一个干净的"应用程序,这意味着当前git不会更改.然后生成一个组件,并查看回购中的更改,以便您可以从那里回溯删除组件所需的操作.

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.

如果您只是想尝试生成什么内容,可以使用--dry-run标志在磁盘上不生成任何文件,只需查看更新的文件列表即可.

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.

这篇关于使用CLI删除组件的最佳方法是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆