I am creating lightning component dynamically. On callback, I am facing a strange error which should not come.
$A.createComponent(
"c:TestComponent",
{
parameter1 : "hey"
},
function(newComponent, status){
var con = component.find('container');
if (component.isValid() && con.isValid() && status === 'SUCCESS') {
var body = con.get("v.body");
body.push(newComponent);
con.set("v.body", body);
}
});
and .cmp file I have
<div aura:id="container" class="slds-align-top">
</div>
and I am getting error in if condition.
con.isValid is not a function
Since container itself is not valid, I am not able to read the body of container where I want to include newly created component? What is wrong?