Skip to content

Instantly share code, notes, and snippets.

@pozil
Created March 23, 2017 13:41
Show Gist options
  • Save pozil/a3c329063871f255b8887cc185f07af0 to your computer and use it in GitHub Desktop.
Save pozil/a3c329063871f255b8887cc185f07af0 to your computer and use it in GitHub Desktop.
Lightning - Passing data down the component hierarchy via attributes and a change handler
<aura:component>
<aura:attribute name="childAttribute" type="String"/>
<aura:handler name="change" value="{!v.childAttribute}" action="{!c.onChildAttributeChange}"/>
<aura:component>
({
onChildAttributeChange : function (component, event, helper) {
console.log("Old value: " + event.getParam("oldValue"));
console.log("Current value: " + event.getParam("value"));
}
})
<aura:component>
<aura:attribute name="parentAttribute" type="String"/>
<c:childCopmponent childAttribute="{!v.parentAttribute}"/>
<aura:component>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment