Angular – How to generate components in a specific folder with Angular CLI

angularangular-clitypescript

I am using Angular 4 with Angular CLI and I am able to create a 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 it with Angular CLI?

Best Answer

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