title: Angular factory returning a promise
body: <p>When my app starts I load some settings from a server. Most of my controllers need this before anything useful can be done. I want to simplify the controller's code as much as possible. My attempt, which doesn't work, is something like this:</p>
  
  <pre><code>app.factory('settings', ['$rootScope', '$http', '$q', function($rootScope, $http, $q) {
      var deferred = $q.defer();
  
      $http.get('/api/public/settings/get').success(function(data) {
          $rootScope.settings = data;
          deferred.resolve();
      });
  
      return deferred.promise;
  }]);
  
  app.controller('SomeCtrl', ['$rootScope', 'settings', function($rootScope, settings) {
      // Here I want settings to be available
  }]);
  </code></pre>
  
  <p>I would like to avoid having a lot of settings.then(function() ...) everywhere.</p>
  
  <p>Any ideas on how to solve this in a nice way?</p>