I have two components OP_Target and OP_Source. I want to navigate to Target from Source. I have implemented lightning:isUrlAddressable in target and trying to get it's url in source. EDIT:- I have added <aura:attribute name="pageReference" type="Object"/> <lightning:navigation aura:id="navService"/> in source component as well.

Source's Code :-

var type = component.get('v.item.Type__c');
var wList = component.get('v.item.wslrList');
var pageReference = {
        type: 'standard__component',
        attributes: {
            componentName: "c__OP_Target",
        state: {
            "c__Type": type,
            "c__wList" : wList
component.set("v.pageReference", pageReference);

    var navService = component.find("navService");
    var pageRef = component.get("v.pageReference");//THIS COMES NULL

    var url=navService.generateUrl(pageRef);
    var defaultUrl = "www.something.com";
        .then($A.getCallback(function(url) {
            component.set("v.url", url ? url : defaultUrl);
        }), $A.getCallback(function(error) {
            component.set("v.url", defaultUrl);

The pageReference comes null. I have removed flexipage implementations as per the
document here. Appreciate any views. Do I need to add something else in target other than isUrlAddressable.


Did you add navigation service to your component xml?

<lightning:navigation aura:id="navService"/>
  • Apologies , I have edited the question. and yes i have added <lightning:navigation aura:id="navService"/> in source component. – Anand Sharma Mar 26 '19 at 8:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.