Hi Elias

I found this weird thing. It´s the first time I had seen this behaviour. I 
got the solution. 

This development has some functionality built.  I saw below

// Retrieve current permissions

dataSourceService.apply(

     permissionService.getPermissions,

    authenticationService.getAvailableDataSources(),

    authenticationService.getCurrentUsername() 

)

    // Resolve promise using settings pages derived from permissions

    /*.then(function permissionsRetrieved(permissions) {

               deferred.resolve(generateSettingsPages(permissions));*/   
This comment was put by me 

.then(*function* permissionsRetrieved(retrievedPermissions) {

permissions = retrievedPermissions;

resolveSettingsPages(); 

});

*I commented code above and add below before this code* 

*var* resolveSettingsPages = *function* resolveSettingsPages() {

*if* (permissions && user)

deferred.resolve(*generateSettingsPages*(permissions, *user*));

};

*And at the end I added below code*

dataSourceService.apply(

userService.getUser,

authenticationService.getAvailableDataSources(),

authenticationService.getCurrentUsername()

)

// Resolving settings pages if possible

.then(*function* userRetrieved(retrievedUser) {

user = retrievedUser;

resolveSettingsPages();

});

*return* deferred.promise;


This way in function *generateSettingsPages, I was able to have access to 
user variable where is role value. So I could solve this matter, doing as I 
mention.*

*Let me tell you is the first time I am working with this Angular stuff.*

*Thanks a lot four your attention Elias.*

*Regards.*


On Tuesday, April 24, 2018 at 12:31:57 AM UTC-5, Gabriel Huerta wrote:

>
> 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.

Reply via email to