I have an array of objects that I iterate over and for each object I create a child component and pass in the object. I need data-binding so changes made inside the child component can be accessed in the parent.
The following code renders the UI correctly but the data-binding is lost. I read that component.getReference()
is used to allow data-binding to aura:attributes. The properties
array does come from an aura:attribute but I don't want to pass the child component the whole array if I don't need to.
createChildComponent : function(prop) {
return ["c:childComponent", {
"property":prop
}];
},
renderProperties : function(cmp, properties) {
let definitions = properties
.map(function(prop){
return this.createChildComponent(prop);
}, this);
$A.createComponents(
definitions,
function(components, status, errorMessage){
...
}
);
}
Any ideas how to get this to work?
Similar questions
Lightning - dynamically creating element and binding it's attributes