title: How can a service return data and multiple promises to a controller?
body: <p>I have defined a service with functions like this:</p>
  
  <pre><code>angular.module('common').factory('_o', ['$angularCacheFactory', '$http', '$q', '$resource', '$timeout', '_u',
  
     function ($angularCacheFactory, $http, $q, $resource, $timeout, _u) {      
  
         var _getContentTypes = function ($scope) {
             var defer = $q.defer();
             $http.get('/api/ContentType/GetSelect', { cache: _u.oyc })
                 .success(function (data) {
                     $scope.option.contentTypes = data;
                     $scope.option.contentTypesPlus = [{ id: 0, name: '*' }].concat(data);
                     $scope.option.sContentType = parseInt(_u.oyc.get('sContentType')) || 0;
                     defer.resolve();
                 })
             return defer.promise;
         };
  
           return {
             getContentTypes: _getContentTypes
         }
  
     }]);
  </code></pre>
  
  <p>I am calling this in my controller like this:</p>
  
  <pre><code>.controller('AdminProblemController', ['$http', '$q', '$resource', '$rootScope', '$scope', '_g', '_o', '_u',
   function ($http, $q, $resource, $rootScope, $scope, _g, _o, _u) {
  
       $scope.entityType = "Problem";
       _u.oyc.put('adminPage', $scope.entityType.toLowerCase());
  
       $q.all([
          _o.getContentTypes($scope),
          _o.getABC($scope),
          _o.getDEF($scope)
       ])
  </code></pre>
  
  <p>Am I correct in saying this is not the best way to use a service. I think I should be returning the 
  content type data and then in the controller assigning to the scope not in the service. </p>
  
  <p>But I am not sure how to do this as my service just returns a defer.promise and I am using $q.all so I think I should populate the scope after $q.all has returned success for every call. </p>
  
  <p>Can someone give me some advice on how I should return data from a service with a promise and have it populate the $scope after $q.all has completed with all calls successful ?</p>