I want to be able to call $A.createComponents(type, attribute, calllback); with values in an array. SF doc I am following: Dynamically Creating Components. But the obvious value of this would be to populate an array and pass it to createComponents.
I am getting this error:
Here is the component:
<aura:component>
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<aura:attribute name="body" type="Aura.Component[]"/>
{!v.body}
</aura:component>
And the controller:
({
doInit: function(cmp) {
debugger;
var typeArray = ["ui:message","ui:message"];
var objArray = [];
var obj0 = {title:"Sample Thrown Error", closable:"true"};
objArray.push(obj0);
var obj1 = {title:"Sample Thrown Error1", closable:"true"};
objArray.push(obj1);
var finalInputs = [];
for(var i = 0; i < typeArray.length; i++){
var type = typeArray[i];
var attributes = objArray[i];
finalInputs.push([type, attributes]);
}
$A.createComponents(finalInputs,
function(components, status, errorMessage){
debugger;
if (status === "SUCCESS") {
var cmps = components;
cmp.set('v.body', cmps);
}
else if (status === "INCOMPLETE") {
console.log("No response from server or client is offline.")
// Show offline error
}
else if (status === "ERROR") {
console.log("Error: " + errorMessage);
// Show error message
}
}
);
},
})