There are couple of methods to create component in a specific directory.
Method 1: "Open in Integrated Terminal" - Quick, Simple and Error free method
i.e. You want to create a component in a app/common
folder as shown in the image given below, then follow these steps
- Right click on the folder in which you want to create component.
- Select option
Open in Integrated Terminal
or Open in Command Prompt
.
- In new terminal (you'll see your selected path), then type
ng g c my-component
Also you can check this process through this image
Method 2: "Copy Relative Path" and Paste on Terminal
- Right click on folder in which you want to create component
- From context menu, select
Copy Relative Path
- On termincal, type
cd
, press space and then ctrl + v to paste the copied path and hit Enter
- You will see that directory has been changed.
Also you can check this process through this image
Method 3: Type complete path on terminal
i.e. You want to create component
in some folder, you type the whole command including path and component name.
Also you can check this process through this image
Note (method-3): angular will not allow you to create component outside app folder so for component, your base path will be app that's why in my case I had to start with auth/a-component
instead of src/app/auth/a-component
ng generate component plainsight
as a parent and now you want to generate a child then just run:ng generate component plainsight/child
– Martin Zamorang generate component path/to/folder/plainsight -d
– Juan Pablo