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?

1 Answer 1

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.

1
  • 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, 2017 at 8:37

You must log in to answer this question.

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