A value returned from a promise can be obtained with below code
service.getRole(username)
.then(*function*(result) {
console.log(result);
role = result;
console.log("role[" + role + "]"); }
});
// But outside from service.getRole this scope is nothing (role does not
have any value)
console.log("Outside role[" + role + "]");
How can I assign result to role? Because this variable is used following
this function and outside.
Beforehand thanks for your valuable help.
--
You received this message because you are subscribed to the Google Groups
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.