AngularJS : get list of objects from service in the controller
<p>I have this service to retrieve a list of cars from a WebAPI server :</p>

<pre class="lang-js prettyprint-override"><code>    angular.module('MyServices')
    .service('carService', ['$http', '$rootScope', 
        function ($http, $rootScope) {

        this.getList =function(userName, ticket)
        {
            $rootScope.$emit('My.OnBusy');

            $http.get('api/car'
               , { params: {userName: userName} }
           ).success(function (data) {
                $rootScope.$emit('My.OnIdle');

                if (data[0] &amp;&amp; data[0].Name == "Error")
                {
                    $rootScope.$emit("My.OnError", data[0].Model);
                    return {};
                }

                return data;
           }).error(function (data, status, headers, config) {
               $rootScope.$emit('My.OnIdle');
               $rootScope.$emit("My.OnError", "Error in communication with server.");
               return {};
           });
        }
    }]
    );
</code></pre>



<p>And in the controller I use it like this :</p>

<pre class="lang-js prettyprint-override"><code>angular.module('MyControllers')
.controller('carController', function CarController($rootScope, $scope, $http, carService) {

    $scope.loadCars = function (userName, ticket) {
        $scope.Cars = carService.getList(userName, ticket);
    }

    $scope.loadCars($rootScope.user.email, '');
});
</code></pre>



<p>But the <strong>$scope.Cars</strong> is Undefined after the cal to <strong>getList</strong>. I tried to use <strong>"then"</strong> when I call the service but it was unsuccessful.</p>

<p>Saying that I want to handle success and error of the operation in the service itself, how can I get final result in the controller?</p>