Created
October 1, 2018 09:21
-
-
Save meajinkya/e3fb41161fa73718aedd141cb2f7a100 to your computer and use it in GitHub Desktop.
Parent/Child Message Passing using Attributes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Parent component "parent.cmp" --> | |
<aura:component> | |
<aura:attribute name="myAttr" type="String" default="world" /> | |
<c:child myAttrChild="{!v.myAttr}"> | |
</aura:component> | |
<!-- Child component "child.cmp" --> | |
<aura:component> | |
<aura:attribute name="myAttrChild" type="String"/> | |
<lightning:input name="input1" label="Enter some text" value="{!myAttrChild}" /> | |
</aura:component> | |
/** | |
* parentController.js | |
*/ | |
({ | |
fooMethod : function(component, event, helper) { | |
var myAttrChild = component.get("v.myAttr"); | |
console.log("myAttrChild: ", myAttrChild); | |
} | |
}) | |
If user enters some value in input1 in child component and then fooMethod is called, | |
myAttr in parent will have the same value as myAttrChild. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment