You need to sign in to do that
Don't have an account?
Nethra Raghupathy
Pass attribute in $A.createComponent()
Hi,
I'm calling a existing component using create component and trying to pass attribute for it.
oneController.js
Indeatails components gets created in component one but console.log of oppId gives me undefined. I couldn't pass the attribute from one component to another.
I'm calling a existing component using create component and trying to pass attribute for it.
oneController.js
var id='25978371'; $A.createComponent( "c:InDetails", { oppId: id, }, function(newCmp){ component.set("v.currentContent", newCmp); } );InDetails.cmp
<aura:attribute name="oppId" type="String"/>InDetailsController.js
console.log(component.get("v.oppId"))
Indeatails components gets created in component one but console.log of oppId gives me undefined. I couldn't pass the attribute from one component to another.
Adding along the complete code.
one.cmp
InDetails.cmp: IndetailsController.js:
HI Nethra Raghupathy,
It works too. I tested these components on a custom app
Where Did you test theirs?
BFClassicApp.app
I used your code and it works for me too also.
Another way to pass attributes from one component to another component.
Please try below code,
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Rambabu
I can't define child component because which component needs to be rendered is dynamic and Its based on the API callback.
The problem here is $A.createComponent is inside API callback and it loses its attribute memory during the callback.
Started a seperate thread for this https://developer.salesforce.com/forums/ForumsMain?id=9062I000000g6gbQAA