Generate inside module folder

Assuming you are in your application's root directory and want to create components inside src/app/documents as you show above, you can use the --flat option to have your component created without creating a directory. To create the component as you request above, use this command:

ng generate component document-list --flat

Using angular-cli you can run ng g component documents/document-list and it will create the structure you need, (assuming app is the root of your application).

enter image description here

Hope this helps.


To create a component inside a folder that either already exist or does not have the same name as the component without creating a sub folder...

ng generate component directory/component-name --flat

For example: ng generate component test/test-list --flat

This will generate the component in the folder test and NOT create a sub folder test-detail... enter image description here