0

I am trying to console an object although it's not throwing any error but the result i want is shown after some time and I am not able to retrieve it.

It shows an i icon which says 'value below was evaluated just now' and I am not able to get that values .

OUTPUT: Promise {$$state: {…}}
        $$state:
        status:1
        value:"Modifier"
        __proto__:Object
        __proto__:Object

And I need that value:"MODIFIER" in a variable. How to get it. Thanks in advance.

console.log($translate('MODIFY')); I am using angular-translate inside a controller.

When I use console.log($translate('MODIFY')['$$state'].value) it shows undefined just because of the reason "value below was evaluated just now". I need the later values or any way to get them before.

Adesh Kumar
  • 952
  • 2
  • 16
  • 33

1 Answers1

2

What you have here is a promise, which will return you values asynchronously(i.e out of the flow of execution). The correct way to handle this is as follows:

promiseObj.then(function(value){//you're code here})

When i was staring out this here helped me understand promises.

http://andyshora.com/promises-angularjs-explained-as-cartoon.html

Hope this helps, Cheers!

Jonathan Dsouza
  • 568
  • 1
  • 5
  • 17