0

i have children component ,i have defining the attributes in mytop level component and then passing these down to my nested components. That way, when the nested component updates the attribute value, it will be immediately reflected in the parent component.

when i want to get the values of my two attributes, i get undefined

parent component

 <aura:attribute name="valueList" type="String"/>
 <aura:attribute name="valuePickList " type="String"/>

<c:PicklistMapping    valuePickList = "{!item.result.value}" valueList = "{!v.valueList}"  /> 

my children component

  <aura:attribute name="ValuePickList" type="String" default="" />
  <aura:attribute name="valueList" type="String"/>    

parent.js

  console.log('value= ' + component.get('v.valuePickList'));
  console.log('value= ' + component.get('v.valueList'));
  • You are not binding the attribute valuePickList in child with the parent's values. You will need to use valuePickList = "{!v.valuePickList}" if you need to bind the values. Take a look at Data Binding Between Components for details. – Jayant Das Aug 27 at 11:43
1

component.get('v.valuePickList') will give you the value of attribute value valuePickList of same component. But as you need the attribute value from child, first you need to identify the child (through aura:id) and then get the attribute value from it:

<c:PicklistMapping  aura:id="mapping"  valuePickList = "{!item.result.value}" valueList = "{!v.valueList}"  />

and in JS:

console.log('value= ' + component.find('mapping').get('v.valuePickList'));
console.log('value= ' + component.find('mapping').get('v.valueList'));

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.