Passing variable through this.Parameter.map returns Observable without value

Hello!

I’m struggling with passing and using a variable through this.Parameter.map(). I have in Page1.js:

router.push("viewProfile", { userId: SelectedFriendId.value });

Then in Page2.js it’s recieved like this (from example found in docs about navigation):

var userId = this.Parameter.map(function(param) {
    return param.userId;
});

Displaying the value in Page2.ux works fine, but then using the variable in Page2.js is a bit of a hassle since it has apparently along the way become an Observable. Well that’s fine but when trying to access that Observable’s .value it simply outputs as “undefined”… How do I use this passed variable in JS???

Thanks in advance.

Hi!

this.Parameter is an observable, correct. This means the value is not available synchronously. Also, it can change at any time, so you need to listen for changes and deal with it accordingly. This is one way :

 this.Parameter.onValueChanged(module, function(param) {
     // use param here 
 }

Ok i see, I’ll give it a try.
Again thanks for the help and quick response :slight_smile: