title: Angularjs - how do I set module values in a service?
body: <p>I have the following services module for an Angular app.</p>
  
  <pre><code>angular.module('rs.services', [])
    .value('uid', null)
  
    .factory('login', ['$http', 'uid', function($http, uid) {
      return function(user, pass) {
        var p = $http.post('/login', {"user": user, "pass": pass})
          .success(function(data, status, headers, config) {
            // set uid
          })
          .error(function(data, status, headers, config) {
            // do something
          });
  
        return p;
      }
    }]);
  
    // a service that uses uid to authenticate the request
    .factory('userPrefs' ['$http', 'uid', function($http, uid) {
      return function() {
        return $http.post('/user/prefs', {"uid": uid});
      }
    }]);
  </code></pre>
  
  <p>After a user logs in, the <code>login</code> service returns a unique session id and I want to set the module's <code>uid</code> value for other services calls to refer to.</p>
  
  <p>I'm pretty sure the above code won't work because I can't use a value as a dependency in the module's configuration stage.  How can I set the <code>uid</code> value in the <code>login</code> service and access it in other services within the module, or if that's not possible how can I make a value that can be set / get by these services?</p>