1

I have 2 components, 1 parent and 1 child.

c:parentComponent

<aura:component >
    <aura:attribute name="passToChild" type="String" required="false" description="" access="private"/>

    <c:childComponent valueFromParent="{! v.passToChild }"

</aura:component>

c:childComponent

<aura:component >
    <aura:attribute name="valueFromParent" type="String" required="false" description="" access="private"/>

    Some text

</aura:component>

I want to get the value of the passToChild attribute and pass it to the child component for futher processing. However, I am getting an error.

Failed to save undefined: No ATTRIBUTE named valueFromParent found: Source

I tried creating an attribute with that name but it still shows the error. Am I doing something wrong?

5

Attribute valueFromParent in c:childComponent has private value of access attribute. It is visible only inside this component. Change it to public, or just remove access attribute

c:childComponent

<aura:component >
    <aura:attribute name="valueFromParent" type="String" required="false" description="" access="public"/>
    Some text
</aura:component>

Refer to documentation

Accessing a private attribute returns undefined unless you reference it from the component in which it’s declared.

| improve this answer | |
  • Oh my god you are a legend! I thought I was doing a wrong call only to find out that it should be public instead. Thanks man! – GibiDroidZ Jul 19 '17 at 8:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.