title: Return a value from AngularJS API service to controller
body: <p>If I have a service that looks like this:</p>
  
  <pre><code>app.factory('User', function($http, User) {
      var User = function(data) {
          angular.extend(this, data);
      };
      User.prototype.create = function() {
          var user = this;
  
          return $http.post(api, user.getProperties()).success(function(response) {
              user.uid = response.data.uid;
          }).error(function(response) {
  
          });
      };
  
      User.get = function(id) {
          return $http.get(url).success(function(response) {
              return new User(response.data);
          });
      };
  
      return User;
  });
  </code></pre>
  
  <p>How do I, in a controller, get the <code>User</code> that was created in the <code>get()</code> function?</p>
  
  <p>Currently what I have is:</p>
  
  <pre><code>app.controller('UserCtrl', function($scope, User) {
      $scope.user = null;
  
      User.get($routeParams.rid).success(function(u) {
          $scope.user = new User(u.data);
      });
  });
  </code></pre>
  
  <p>The issue is that the <code>UserCtrl</code> is getting the api response, not the value returned from the <code>success()</code> in the factory. I'd prefer to be making the new user in the factory, as opposed to passing the api response to the controller.</p>