Maybe more of a js question but how do I call a function in  a service 
object from within another object in that service?
In this example: how do I call getUserInfo from within the 'then' function 
inside the login function?

myAppModule.service('Service', ['APIService','LoginModel', 'UserModel', 
function(APIService, LoginModel, UserModel) {
    
    return {
        
        login : function(username,password)
        {
            var data = [
                {
                    command:"login",
                    username:username,
                    password:password
                }];

            APIService.call(data).then(function(data) {
                console.log('login data', data);
                LoginModel.setLoggedIn(true);
                getUserInfo();//HOW DO I CALL getUserInfo() FROM HERE?
            });
        },


        getUserInfo : function()
        {
            var data = [{command:"userinfo"}];

            APIService.call(data).then(function(data) {
                    UserModel.onUserInfo(data.commands[0]);
            });
        }
    }
}]);

I aslo want to call login and getUserInfo from a Controller which is 
working fine with the code above,

thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" 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 http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to