title: Return promise from Angular service
body: <p>I have a service that (when it's all said and done) updates a value on the database. </p>
  
  <p>I would like to update the view scope based on the result (success/fail) but of course the http request used by the service is asynchronous so the return value is not immediately available and comes up undefined in the controller. </p>
  
  <p>If I were making the http request inside the controller, I would update the scope inside the callback function, but because Im using a service, the scope's umm... scope(?) is not available to it. </p>
  
  <p>Im thinking a Promise is what I need to be returning but perhaps there is something more simple.</p>
  
  <p><strong>SERVICE</strong></p>
  
  <pre><code>.service('doStuff',function($http){
  
      this.update = function(data) {
  
          $http.post('http://api.internet', data).then(function(res){ 
  
              return(res.data.result);
  
          });  
  
      }
  
  })
  </code></pre>
  
  <p><strong>CONTROLLLER</strong></p>
  
  <pre><code>/* service is injected into controller etc. */
  
  var result = doStuff.update(data);
  
  p(result); // undefined (as expected)
  </code></pre>
  
  <p>I figured since Im returning from the http callback, it would wait for the result to be available before returning but I guess Im missing something.</p>