Angular-cli: ng g component in folder where currently residing creates component in root

Created on 15 Dec 2016  路  13Comments  路  Source: angular/angular-cli

when create a component in currently residing folder, my component is created in root structure:
ngcli1

/c/dev/ng2clienttracker/src/app/clients/components
ng g component new-cmp
installing component
create srcappnew-cmpnew-cmp.component.css
create srcappnew-cmpnew-cmp.component.html
create srcappnew-cmpnew-cmp.component.spec.ts
create srcappnew-cmpnew-cmp.component.ts

2 (required) bufix

Most helpful comment

@NilsHolger Here is the Answer.

Consider your project is recipe-book.
first navigate to app folder by

  1. cd src
  2. cd app

then if you wants to create folder in app then simply type
ng g c test

it will create in app folder
now you wants to create component inside of test then type
ng g c test/test2
it will create new component in test folder. see below pic

newcoponent

All 13 comments

Could you fill out issues template to show what kind of version of the CLI you are using etc?

FYI, I am not having this issue on 1.0.0Beta-21 on macOS 10.12.2 with node 7.2.1 npm 4.0.3

@NilsHolger Here is the Answer.

Consider your project is recipe-book.
first navigate to app folder by

  1. cd src
  2. cd app

then if you wants to create folder in app then simply type
ng g c test

it will create in app folder
now you wants to create component inside of test then type
ng g c test/test2
it will create new component in test folder. see below pic

newcoponent

As @Nikki1993 said, please follow the questionnaire provided when opening a new issue. I tried this on MacOSX Sierra and cli 1.0.0.beta.22-1 and it works properly.

screen shot 2016-12-15 at 12 22 12 pm

This seems windows specific.

No, this is not windows specific. I'm use angular-cli 1.0.0-beta24 and component not created in another component folder, but in root.

I have this issue in Ubuntu 16.04 and CLI version 1.0.0-beta.24

I have this issue on Windows 10, since beta version .23. I'm currently on 1.0.0-beta.24

@NilsHolger Here is the Answer.

Consider your project is recipe-book.
first navigate to app folder by

  1. cd src
  2. cd app

then if you wants to create folder in app then simply type
ng g c test

it will create in app folder
now you wants to create component inside of test then type
ng g c test/test2
it will create new component in test folder. see below pic

newcoponent

I have just tried to recreate this issue unsuccessfully, closing this issue as it cannot be reproduced, if you're still having the issue, please comment and we will re-evaluate.

Here is a screen-grab of my attempt to recreate. (with version 1.0.0-beta.25.5)

image

Angular CLI: 1.6.4

  • Navigate at root of your project (test-app in this case)
  • issue command ng g c parentfolder/componentname (ng g c form-test/form-test-child in this case)

image

Result

image

I do not want app folder, I want if I run ng g c test then test folder will generate in src

ex:
ng g c test
it will generate in "src/app/test"
I do not want app folder here I want test folder is in src.

please suggest

I think maybe lost in this thread was a question about how to specify the output directory of the generate command.

For example, right now it will always prefix the path with _app/_.

$ ./node_modules/.bin/ng generate component component/navigation
CREATE src/app/component/navigation/navigation.component.scss (0 bytes)
CREATE src/app/component/navigation/navigation.component.html (29 bytes)
CREATE src/app/component/navigation/navigation.component.spec.ts (656 bytes)
CREATE src/app/component/navigation/navigation.component.ts (346 bytes)

Would be great to get the result, but without _app/_, eg.

CREATE src/component/navigation/navigation.component.scss (0 bytes)

Is this possible through _angular.json_ or CLI?

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

brtnshrdr picture brtnshrdr  路  3Comments

sysmat picture sysmat  路  3Comments

jbeckton picture jbeckton  路  3Comments

donaldallen picture donaldallen  路  3Comments

gotschmarcel picture gotschmarcel  路  3Comments