You need to sign in to do that
Don't have an account?
Vigneshwaran Loganathan
Pass Parameter Using Lightning Navigation
Hi All, The link https://rajvakati.com/2018/11/13/navigate-to-component-using-lightningnavigation/ where Source Component passes parameters to Target and the parameters are visible in URL..
I am following the exact steps but its not passing parameters to mt Target Component, neither can I see any Parameters in URL.. Is there anything I am doing wrong?
I have added the component in Account Details Page..
Source.cmp
Target.cmp
I am following the exact steps but its not passing parameters to mt Target Component, neither can I see any Parameters in URL.. Is there anything I am doing wrong?
I have added the component in Account Details Page..
Source.cmp
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" > <lightning:navigation aura:id="navService"/> <aura:attribute name="pageReference" type="Object"/> <aura:attribute name="url" type="String"/> <aura:handler name="init" value="{! this }" action="{! c.init }"/> <lightning:button label="Open Lightning Component" onclick="{!c.handleClick}"/> </aura:component>SourceController.JS
({ init : function(cmp, event, helper) { var navService = cmp.find("navService"); var pageReference = { "type": "standard__component", "attributes": { "componentName": "c__Target" }, "state": { "firstName": "Test" , "lastName": "user" } }; cmp.set("v.pageReference", pageReference); var defaultUrl = "#"; navService.generateUrl(pageReference) .then($A.getCallback(function(url) { cmp.set("v.url", url ? url : defaultUrl); }), $A.getCallback(function(error) { cmp.set("v.url", defaultUrl); })); }, handleClick: function(cmp, event, helper) { var navService = cmp.find("navService"); // Uses the pageReference definition in the init handler var pageReference = cmp.get("v.pageReference"); event.preventDefault(); navService.navigate(pageReference); } })
Target.cmp
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,lightning:isUrlAddressable" access="global" > <aura:handler name="init" value="{!this}" action="{!c.init}" /> <aura:attribute name="firstName" type="String" /> <aura:attribute name="lastName" type="String" /> <div> Full Name : {!v.firstName} + {!v.lastName} </div> </aura:component>TargetController.JS
({ init: function(cmp, event, helper) { var pageReference = cmp.get("v.pageReference"); cmp.set("v.firstName", pageReference.state.firstName); cmp.set("v.lastName", pageReference.state.lastName); } })
Below is the URL which when I clicked from Account Page - without Parameters
Thanks
Vignesh
Best Answer chosen by Vigneshwaran Loganathan
Vigneshwaran Loganathan
I have posted the same and got answer here -- https://salesforce.stackexchange.com/questions/274242/pass-parameter-using-lightning-navigation#274244