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
harry.kimharry.kim 

I'd like to get URL paramaters from {!v.pageReference} but, it is null..

To get paramater I used this code..

<aura:component implements="lightning:isUrlAddressable,lightning:hasPageReference" >
{!v.pageReference.state}

but, {!v.pageReference} is null.

how can I get a URL paramater in the lightning component????
Amit Chaudhary 8Amit Chaudhary 8
Please check below post.
1) http://bobbuzzard.blogspot.com/2018/06/accessing-url-parameters-in-summer-18.html

I hope that will help you.

try like below. Add Param as well.

 {!v.pageReference.state.param1}
 
Raj VakatiRaj Vakati
Here is the example 


hellotarget.cmp
 
<aura:component implements="lightning:isUrlAddressable" description="c:helloTarget component">
    <aura:attribute name="firstname" type="String" />
    <aura:handler name="init" value="{!this}" action="{!c.init}"/>
    Hello {!v.firstname}.
   
</aura:component>
 
({
    init: function(cmp, evt, helper) {
        var myPageRef = cmp.get("v.pageReference");
        var firstname = myPageRef.state.c__firstname;
        cmp.set("v.firstname", firstname);
    }
})


hello.cmp
 
<aura:component description="c:hello component" implements="flexipage:availableForAllPageTypes">
    <aura:attribute name="pageReference" type="Object"/>
    <aura:handler name="init" value="{! this }" action="{! c.init }"/>
    <lightning:navigation aura:id="navService"/>
    <lightning:button label="Navigate" onclick="{!c.handleClick}"/>
</aura:component>
 
({
    init : function(component, event, helper) {
        var pageReference = {
            type: 'standard__component',
            attributes: {
                componentName: 'c__helloTarget',
            },
            state: {
                "c__firstname": "John"
            }
        };
        component.set("v.pageReference", pageReference);
    },
    handleClick: function(component, event, helper) {
        var navService = component.find("navService");
        var pageReference = component.get("v.pageReference");
        event.preventDefault();
        navService.navigate(pageReference);
    }
})


https://rajvakati.com/2018/12/05/navigate-to-component-using-lightning-navigation-api/