title: service not returning value
body: <p>I have been working to write a service to return username.</p>
  
  <pre><code>var username, $promise;
  
  angular.module('TestApp').factory('UserService', function($http) {
  $promise= $http.get('/api/getuser')
  .success(function(data) {
    username = data;
  });
  
  $promise.then(function() {
  return username;
  });
  });
  </code></pre>
  
  <p>But injecting this service in an controller would return in an undefined value</p>
  
  <pre><code>angular.module('TestApp')
  .controller('UserLoginController', function($scope, UserService){
  console.log("Username is: "+ UserService);
  });
  </code></pre>
  
  <p>I have confirmed that http get request returns valid username value. I am quite new to angular and would really appreciate if anyone can point out what am I doing wrong here.</p>