Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hi!!! your book is a great resource, but just two questions... #30

Closed
LorenzoCorbella74 opened this issue Sep 14, 2015 · 2 comments
Closed

Comments

@LorenzoCorbella74
Copy link

In the authService the { cache: true } expedient is ok for performance but if I logout and then I log in with a new user the link on the nav bar remains with the name of the previous logged user. Refreshing the page solves the issue.

In the mainCtrl (code below) the vm.user obj is only available inside the promise but outside is undefined. Is there a way to make it available to the other functions of the controller?

    // get user information on page load
        Auth.getUser()
            .then(function(data) {
                vm.user = data.data;
                console.log("inside: ", vm.user); // obj...
            }); 
        console.log("outside: ", vm.user);      // undefined
    });

Bye for now, ciao

@chris-sev
Copy link
Member

Binding it to vm directly binds it to the controller outside of the scope of the promise as long as you have vm = this; in the beginning of your controller. Is this not the behavior you are seeing?

Try console.logging just console.log(vm.user);

@LorenzoCorbella74
Copy link
Author

I have vm = thisat the very beginning but my problem was that being a promise the data was available after a certain amount of time and the other binds were flickering (interpolation problem) till that time. I solved by using the resolve property of the route, so data is already there when the view is open.
Ciao e grazie!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants