Is it possible to generate multiple Angular components using single angular-cli command like ng generate component comp1, comp2, comp3?

旧街凉风 提交于 2019-12-30 02:19:06

问题


I need to create ten Angular components like comp1, comp2, comp3, comp4, ..., comp10. So I need to execute same command for ten times for each component like ng g c comp1, ng g c comp2, etc.

Is there any option to generate multiple angular components using single angular-cli command like ng g c comp1, comp2, comp3.


回答1:


Well, there is nothing as of now by Angular CLI to create multiple components. But this can be done trivially in any shell.

Run this command into your bash shell -

for i in comp1 comp2; do ng g c "${i}"; done

Special thanks to Ingo Bürk's answer




回答2:


Microsoft Windows variants

In root:

for %n in (component-name-1, component-name-2, ...) do ng g c %n

In module:

for %n in (component-name-1, component-name-2, ...) do ng g c module-name/%n

In module, without tests:

for %n in (component-name-1, component-name-2, ...) do ng g c module-name/%n --skipTests=true

Angular - ng generate

Windows CMD FOR command reference



来源:https://stackoverflow.com/questions/51185021/is-it-possible-to-generate-multiple-angular-components-using-single-angular-cli

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!