More often than not, we need to generate our Angular components inside specific folders for the sake of better structuring our application.
This is how I use Angular CLI to generate a component inside a specific folder.
We can simply use the ng g c command followed by the folder path as follows:
ng g c
ng g c buttons/home
This command will generate a home component inside the app/buttons/home folder.
home
app/buttons/home
Please note that if the buttons folder doesn’t exist Angular CLI will automatically create it.
buttons
If you don’t want to have the home subfolder created, you simply need to add the --flat option to the command as follows:
--flat
ng g c buttons/home --flat
This command will generate the files of the home component directly inside the app/components/ folder.
component
app/components/
This is all for this thread, if you have other tips related to this topic please share them below!
Published at WebTutPro.
How to generate Angular components in a specific folder?
How to generate Angular components in a specific folder?
How to generate Angular components in a specific folder?
More often than not, we need to generate our Angular components inside specific folders for the sake of better structuring our application.
This is how I use Angular CLI to generate a component inside a specific folder.
We can simply use the
ng g c
command followed by the folder path as follows:This command will generate a
home
component inside theapp/buttons/home
folder.Please note that if the
buttons
folder doesn’t exist Angular CLI will automatically create it.If you don’t want to have the home subfolder created, you simply need to add the
--flat
option to the command as follows:This command will generate the files of the
home
component
directly inside theapp/components/
folder.This is all for this thread, if you have other tips related to this topic please share them below!
Published at WebTutPro.