3

I wish to make dynamic aura:id's and for that i want to use $A.createComponent, now i already have a component called 'pageComponentCard' that i wish to call but i can't do this.

The code in question:

    $A.createComponent(
        "c:pageComponentCard",
        {
            "component":"{!v.cardId}",
        },
        function(newCard, status, errorMessage){
            if (status === "SUCCESS") {
                var body = cmp.get("v.body");
                body.push(newCard);
                cmp.set("v.body", body);
            }
            else if (status === "INCOMPLETE") {
                console.log("No response from server or client is offline.")
            }
                else if (status === "ERROR") {
                    console.log("Error: " + errorMessage);
            }
        }
    );

Both tried with and without the "c:"

3

The mistake is at passing attribute value to pageComponentCard "component":"{!v.cardId}", {!v.cardId} it is used in component markup . you must use component.get("v.cardId") to get attribute value.in controller.

$A.createComponent(
        "c:pageComponentCard",
        {
            "component":component.get("v.cardId"),
        },
        function(newCard, status, errorMessage){
            if (status === "SUCCESS") {
                var body = cmp.get("v.body");
                body.push(newCard);
                cmp.set("v.body", body);
            }
            else if (status === "INCOMPLETE") {
                console.log("No response from server or client is offline.")
            }
                else if (status === "ERROR") {
                    console.log("Error: " + errorMessage);
            }
        }
    );
  • Thanks for your comment! The console does generate the following: " Error: Unknown component 'markup://nvmsconfigtool:pageComponentCard'. ", any idea? – Olsthoorn Apr 10 '17 at 9:09
  • please post a component markup code c:pageComponentCard component.and you cant use attribute name as component it may cause error. – vignesh Apr 10 '17 at 9:13

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.