Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular - how to create a child component using Angular CLI

I have created an Angular app using Angular CLI and created one component: ng g c parent.

How do I create child components (e.g. child1 and child2) and integrate them with a parent using angular CLI?

I am trying to create a simple example and understand in some example parent-child component relationship.

like image 681
Joe Avatar asked Sep 13 '26 01:09

Joe


1 Answers

If you mean to nest the components into the parent you can do it like this

ng generate component parent/child1
ng generate component parent/child2

This generates the child components inside the parent folder. I do this in my apps to keep together what belongs together! Hope it helped

like image 190
Marvin W. Avatar answered Sep 14 '26 15:09

Marvin W.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!