1

I understand this is in beta still but want to make sure i'm not doing anything wrong here. I have a component on Account detail page that is just a button and some text. Once the button is clicked it should take the user to a new component (which is a form to enter a child record).

When i try to add this component to an App to test or try to add it to the Account details page.. i get an uncaught error. What am i doing wrong here? Thanks

<aura:component access="global" implements="flexipage:availableForRecordHome,force:hasRecordId">
    <ltng:require styles="{!$Resource.lightning +
         '/assets/styles/salesforce-lightning-design-system.css'}"/>
    <aura:attribute name="recordId" type="Id"/>
        <lightning:button variant="brand" label="enterChildObject" onclick="{! c.navigateToChildObjectComponent }" />


</aura:component>

clientside controller:

({
    navigateToChildObjectComponent : function(component, event, helper) {
        var accId = component.find("recordId").get("v.value");
        var evt = $A.get("e.force:navigateToComponent");
        var evt.setParams({
            componentDef : "c:childObjectComponent",
            componentAttributes: {
                accountId : component.get(accId)
            }
        });
        evt.fire();
    }
})

1 Answer 1

2

To get the value of a aura:attribute, you should do : component.get("v.attributeName")

After fixing few typos and above changes navigateToChildObjectComponent method will look like below:

navigateToChildObjectComponent : function(component, event, helper) {
    var evt = $A.get("e.force:navigateToComponent");
    evt.setParams({
        componentDef : "c:childObjectComponent",
        componentAttributes: {
            accountId : component.get("v.recordId")
        }
    });
    evt.fire();
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .