I am following this link 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
<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}"/>
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>
({
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);
}
})
When I click the button, URL is now showing any parameter.. Is there anything wrong?