1

I see some strange behavior with lightning:isUrlAddressable tab. When I try to enter the parameter after loading the page immediately parameter is removed from the URL and component is not able to find the param value.

Simple Cmp:

<aura:component  implements="lightning:isUrlAddressable,force:appHostable" access="global">
    <aura:attribute name="urlParam" type="string"/>
    <div class="slds-card">
        If you implements "lightning:isUrlAddressable" interface, then by 
        using v.pageReference,you can get URL params.
        <div class="slds-box">  
            Account name from URL parameter: <b>{!v.pageReference.state.accname}</b>
        </div>
    </div> 
</aura:component>

Screenshots: enter image description here

param is disappeared after pressing the ENTER button

enter image description here

6
  • This works quite fine for me, try in some other browser?
    – Raul
    Feb 25, 2019 at 16:07
  • Could be a Lightning Component Tab issue. Try addressing the component itself (as per this documentation), which will look something like: /lightning/cmp/c__myTestCmp?accname=Ajay. Also see this post for a full example Feb 25, 2019 at 18:08
  • I tried in firefox browser too, it is same behavior.
    – Ajay
    Feb 25, 2019 at 18:26
  • @BrianMiller: Yes I tried your approach too, same behaviour, immediately after page load params are disappeared.
    – Ajay
    Feb 25, 2019 at 18:27

2 Answers 2

4

Here I found it in the document that we should add default namespace C__ to the parameters.

lightning/n/Test_Cmp?c__accname=ajay

This worked for me.

3
2

Well this is some fun stuff. Although the documentation says you have to add "c__" to component name, I had the same issue when I didn't add "c__" to the param names.

For example:

https://<Instance>.lightning.force.com/lightning/cmp/c__CheckInCheckOut?step=123

Was loading the page without any parameter in the state variable. See below the console.log of the pageReference:

{"type":"standard__component","attributes":{"componentName":"c__CheckInCheckOut"},"state":{}}

And the parameters after the "?" were not there anymore after load:

https://<Instance>.lightning.force.com/lightning/cmp/c__CheckInCheckOut

So I tried with both

https://<instance>.lightning.force.com/lightning/cmp/c__CheckInCheckOut?c__step=123

And that Worked.

{"type":"standard__component","attributes":{"componentName":"c__CheckInCheckOut"},"state":{"c__step":"123"}}

If anyone has an idea why it only works like that for me and seems to work another way for others i'd be curious to know.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .