+ Start a Discussion
Arun pattnaik 17Arun pattnaik 17 

how to get all the child components in controller js

i want to get all the list of child components in js controller.
Khan AnasKhan Anas (Salesforce Developers) 
Hi Arun,

Greetings to you!

You can use aura:method or events. Please refer to the below links which might help you further with the above requirement.





I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
Arun pattnaik 17Arun pattnaik 17
Hello Anas,
ITs not regarging communicating with components. more over how to get the list of components inside a component in js.
Kranthi Kumar 118Kranthi Kumar 118
Hi Arun,

If you are using Iteration in creating child component you can make use of Events and List attribute to store the created compoonents.

Parent Component:

<aura:attribute name="childcomponents"  type="List"/>
<aura:handler name="cmpevent" event="c:cmpEvnt" action="{!c.addCmpToList}"
      <c:childComponent />

child Component :
<aura:registerEvent name="cmpEvent" type="c:cmpEvent"/>
<aura:handler name="init" value="{!this}" action="{!doinit}"/>

doInit: function(cmp,event,helper){
//Get the Custome Event
//Assign the cmp to the event as parameter
//fire the Event 

Catch the fired event in parent controller addCmpToList Method  and  retrive the created component from event and  push into the List.

Kindly Let me know if it helps you to solve your query...

Thanks And Regards,