function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
prati@salesforceprati@salesforce 

Calling a lightning component from another component on a button click

Hi  all,
I am having an issue with calling a component from another. There are other parts to my component but I am posting a part of my code.
The first component is calling the second component on a button click which calls the function callSaveComp: I am trying to pass the record id of the current record since the first component is on the Account page. So using "v.recordId" in the controller. I can see that v.recordId has the value of the account record but it doesn't get passed to the next component on button click.
<aura:component controller="PartnerAffiliates" implements="flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction,force:appHostable" access="global" >

other code.....
        <lightning:button variant="neutral" label="New" onclick="{!c.callSaveComp}"/>

</aua:component>


controller for first component:
callSaveComp : function(component, event, helper){
        var evt = $A.get("e.force:navigateToComponent");
        console.log('Event '+evt);
        var accountFromId = component.get("v.recordId");
        evt.setParams({
            componentDef  : "c:AffiliateSaveForm" ,
            componentAttribute : {
                accId : accountFromId
            }
        

        });
      
        evt.fire();
}

Second component:
<aura:component access="global" controller="PartnerAffiliates" implements="force:appHostable">
     <aura:attribute name="accId" type="String" access="global"/>
    Other stuff....
</aura:component>

Is it possible to do something like this? or do I have to use lightning Events?


Thank you
prati@salesforceprati@salesforce
Never mind. I figured out what was the issue. I made a small mistake. I was using
 evt.setParams({
            componentDef  : "c:ChildCompo" ,
            componentAttribute : {
                accId : accountFromId
               
            }
instead of evt.setParams({
            componentDef  : "c:ChildCompo" ,
            componentAttributes : {
                accId : accountFromId
               
            }

replaced componentAttribute to componentAttributes . 
SFDCIronManSFDCIronMan
can i get you code