My Lightning Application Opens on click of a button from Opportunity. Application has 1 Parent Component which holds 2 child components. Now, When application gets loaded i am making external callout and getting JSON Response from Parent Components's init method (Calling Apex from JS Controller) and setting 2 attributes (1-1 Each for Child Component) on parent component. So, Now i am passing relevant attribute to Child component and using this attribute value in it's init method. But problem is apex response from parent init is async in Lightning. And Hence i am not able to get this attribute value in child components init method, it is coming as null.

The reason why i am not calling apex from child is because that component is reusable and the response from external callout is not only for this components it contains lot other data to be used for other components.

2 Answers 2


Use a change handler.

For this attribute:

<aura:attribute name="something" type="String"/>

Define this handler:

<aura:handler name="change" value="{!v.something}" action="{!c.handleSomethingChange}"/>

That way, when you set the child attribute from the parent, your change handler will detect it and fire whatever logic you need.


Check this

Parent component:

<!-- This value is set from the external callout -->
<aura:attribute name="something" type="String"/>

<aura:if isTrue="{!not(empty(v.something))}">
  <!-- renders only when "something" has a value -->
  <c:childComponent something="{!v.something}" />

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .