0

I have two different community pages, and on each page I have different component. I need to pass value from first component to other on click. I already have an event which navigates to that other page. I tried with application event and didn't succeed.

1 Answer 1

0

We've been doing this using well defined keys in sessionStorage:

// in your initiating component
sessionStorage.setItem('myValueToPassThrough', 'abc');

Then in the init handler of your second component add:

handleInit: function(cmp, event, helper) {
    var value = sessionStorage.getItem('myValueToPassThrough');
    // you may also want to wipe it out - but be aware it then won't be there on page reload
    sessionStorage.removeItem('myValueToPassThrough');
}
2
  • I was thinking about localStorage too, but I don't know is it a good practice? Are you sure there is no other "more lightning" way? Thanks. Commented Jul 12, 2017 at 7:40
  • I haven't seen a more Lightning way for passing data between pages unfortunately. I'd recommend not to use localStorage because it's shared between tabs and persistent between sessions. sessionStorage is better suited. Commented Jul 12, 2017 at 7:48

You must log in to answer this question.

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