How to access the JSON object. $$ state.value?

Warning: I will sound as if I have no idea what I'm talking about, because I don't seem to know. I participate in the Javascript and AngularJS self-learning process with a lot of trial and error.

I have javascript code (hesitating to copy here because it is a mess) that returns an object with the following structure: enter image description here

What I want to save for the variable is the object corresponding to the object. $$ state.value in the picture. This object has a username, hash and salt that excite me. I don’t know what other things are, such as the state of $$, or how they got there.

However, if I do this (call the main object "whatIHave"):

var whatIWant = whatIHave.$$state.value;

this does not work. whatIWant is null.

Anyone find out what is going on here? What is the state of $$, how did it get there, and how can I extract the desired value?

+4
source share
1 answer

So this is a promise. You need to do something like:

whatIHave.then(function(whatIWant) {
  // Work here
});

I highly recommend you study what a promise is (e.g. link )

If you are interested in what this is $$stateand what it is value, I’ll explain a little:

promises has $$stateand there angular saves all the callback functions that you want to call in the array pending(all those functions that you registered with .then, as I explained earlier).

It also has the status: allowed (1) and rejected (2)

, resolve reject , , , value.

, , value, ( , async).

, , promises, , whatIHave.

+11

All Articles