title: How to correctly pass data from Service to Controller
body: <p>I am trying to send data from my http service to my controller. The service correctly gets the data but it doesn't get sent to the controller.</p>
  
  <p>Now, I am aware that the query is done asynchronously which is why I am trying to use $q.defer. 
  I tried following the example provided by a similar question : <a href="https://stackoverflow.com/questions/27238928/angularjs-http-call-in-a-service-return-resolved-data-not-promises#">AngularJS $http call in a Service, return resolved data, not promises</a> , however it still doesn't work.</p>
  
  <p>Here is my Service :</p>
  
  <pre><code>.service("builds", ['$http', '$q', function($http, $q) {
    var deferred = $q.defer();
  
    $http({
        method:'GET',
        url: '/builds',
        cache : true
    }).success(function(data) {
        deferred.resolve(data);
    }).error(function(msg){
        deferred.reject(msg);
    });
    console.log(deferred.promise);
    return deferred.promise;}]);
  </code></pre>
  
  <p>And here is my routeProvider</p>
  
  <pre><code>$routeProvider.
      when('/builds', {
          controller: ['$scope', 'buildsData', function ($scope, buildsData) {
              console.log("In routeprovider:" + buildsData);
              $scope.allBuilds = buildsData;
          }],
        template: '&lt;build-list&gt;&lt;/build-list&gt;',
        resolve: {
            buildsData: ['builds', function(builds){
                return builds;
            }]
        }
      })
  </code></pre>
  
  <p>And finally here is a snippet of my Controller : </p>
  
  <pre><code>var app = angular.
   module('buildList').
    component('buildList', {
     templateUrl: 'build-list/build-list.template.html',
      controller: function BuildListController($scope, $window,$location,$cookies, builds) {
       console.log($scope.allBuilds);
       $scope.league = $scope.allBuilds;
  </code></pre>