9

want to create nested component in angular 6 . Folder structure is src->app->content->1.home,2.product want create component in product. i did this am on already in folder product c:/users/admin/project/test/src/app/content/product> ng g component advisory on cmd

Getting Error as : Unexpected token / in JSON at position 1122

3 Answers 3

23

Source copied from the official angular-cli doc

ng generate component my-new-component
ng g component my-new-component  // using the alias

// components support relative path generation
// if in the directory src/app/feature/ and you run
ng g component new-cmp
// your component will be generated in src/app/feature/new-cmp
// but if you were to run
ng g component ./newer-cmp
// your component will be generated in src/app/newer-cmp
// if in the directory src/app you can also run

    ng g component feature/new-cmp

// and your component will be generated in src/app/feature/new-cmp
Sign up to request clarification or add additional context in comments.

Comments

5

Go to the root directory where angular-cli is there

and give the command as follows

c :/users/admin/project/test/src/app/content > ng g c product/advisory

Comments

2
C:\depot\sandbox>ng g c outside
CREATE src/app/outside/outside.component.html (22 bytes)
CREATE src/app/outside/outside.component.spec.ts (635 bytes)
CREATE src/app/outside/outside.component.ts (274 bytes)
CREATE src/app/outside/outside.component.scss (0 bytes)
UPDATE src/app/app.module.ts (546 bytes)

C:\depot\sandbox>ng g c outside/inside
CREATE src/app/outside/inside/inside.component.html (21 bytes)
CREATE src/app/outside/inside/inside.component.spec.ts (628 bytes)
CREATE src/app/outside/inside/inside.component.ts (270 bytes)
CREATE src/app/outside/inside/inside.component.scss (0 bytes)
UPDATE src/app/app.module.ts (636 bytes)

C:\depot\sandbox>ng g c outside/inside-too
CREATE src/app/outside/inside-too/inside-too.component.html (25 bytes)
CREATE src/app/outside/inside-too/inside-too.component.spec.ts (650 bytes)
CREATE src/app/outside/inside-too/inside-too.component.ts (285 bytes)
CREATE src/app/outside/inside-too/inside-too.component.scss (0 bytes)
UPDATE src/app/app.module.ts (740 bytes)

Example taken from angular bug tracker on github.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.