call one component from another component lightning code example

Example 1: calling lightning component from another lightning component

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();

Example 2: calling lightning component from another lightning component

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();

Tags:

Misc Example