Reputation: 10412
I have a function that returns deferred promise in Angular.
I have used $$state
to access its values from calling class but not sure if this is the right way.
Should I use .then
instead or is there any standard way to access a specific variable for $q.deferred
Promise object?
Upvotes: 1
Views: 594
Reputation: 67296
Yes, you should not be accessing $$state
directly. Use a .then
to define a callback that will have the data passed to it.
For example:
var promise = service.getDefferredPromise();
promise.then(function(data) {
//use the data
$scope.something = data.something;
});
Upvotes: 1