title: How to get the value returned in the service to a controller in angular?
body: <p>I have  a service function like below.</p>
  
  <pre><code>app.service('UserService',['userFactory',function(userFactory)) {
  
    this.fetchAllUsers =function(){
    userFactory.getUsers(function(data){
    return data['body'];          //Return Array of objects         
  
    }),function(error){
              console.log("error while retrieving users")
    }
  }
  }])
  </code></pre>
  
  <p>I want to call this function in the controller and assign what ever the returned value to a variable. I tried out the following way</p>
  
  <pre><code>$scope.usersList=userService.fetchAllUsers();
  </code></pre>
  
  <p>But $scope.usersList is undefined. How can I get the returned value from the service.</p>