How to generate components in a specific folder with angular-cli?

user8520658 picture user8520658 · Oct 20, 2017 · Viewed 278.2k times · Source

I am using angualr4 with angular-cli and I am able to create new component with the following command.

E:\HiddenWords>ng generate component plainsight

But I need to generate a child component inside plainsight. Is there a way to do with angular-cli?

Answer

user3611927 picture user3611927 · Jan 19, 2018

The ng g component plainsight/some-name makes a new directory when we use it.

The final output will be:

plainsight/some-name/some-name.component.ts

To avoid that, make use of the flat option ng g component plainsight/some-name --flat and it will generate the files without making a new folder

plainsight/some-name.component.ts