Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create nested Component Angular 6

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

like image 726
vedika shrivas Avatar asked May 23 '18 10:05

vedika shrivas


People also ask

Does Angular 6 provide nested components?

Angular allows us to have a different child, or nested component, which is the same component we normally use in an Angular application.

Can you nest components in Angular?

What are Angular Nested Components? The Angular framework allows us to use a component within another component and when we do so then it is called Angular Nested Components. The outside component is called the parent component and the inner component is called the child component.


2 Answers

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
like image 152
Anuradha Gunasekara Avatar answered Sep 24 '22 20:09

Anuradha Gunasekara


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
like image 39
Padmapriya Vishnuvardhan Avatar answered Sep 24 '22 20:09

Padmapriya Vishnuvardhan