Am having this issue, where when I generate components with Angular CLI instead of generating them in the same folder I have CD in it generate them in the App folder. Lets say I have CD to App/Recipe and I use this "ng g c recipe-item" it will be generated in App folder instead of Recipe.

Add a comment
|
2 Answers
if you want to generate a new component called recipe-item inside of the recipe directory:
ng g c recipe/recipe-item
See page 2: https://cli.angular.io/reference.pdf -> ng generate -> Valid types: -> component
Comments
as shown on angular-cli page
components support relative path generation
try using
ng g component recipe-item
5 Comments
G B
From the documentation it shows that, but when I try it it doesn't work. I have edited the quoin by adding a screen shot of the same.
candidJ
src/app/new-cmp/new-cmp.component.html is created corrected by the ng g component recipe-item. check your folder structure once.G B
What I want to achieve here is src/app/test/newcmp.component.html. I am already at in the folder Geralds-MacBook-Pro:test gbrigens$.
candidJ
it is going to create a separate folder for your component (that's how cli works). if you want to achieve
src/app/test/newcmp.component.html then you have to manually add the files (which i won't recommend). when you would have executed ng g component test then test folder with all the component files were created. so if you want to have new-cmp component file in test folder, then you have to manually do it . running ng g component xyz would create xyz folder with all the component files. hope I'm clear.G B
Yea, you are right, if I don't want to create a folder for it I will use "--flat" flag, If you have time check out this tutorial from mindspace youtube.com/watch?v=DBjPIabiRNg min31 the guy generates components in the same path.