we are trying to get data from service agrService with $http its working but when i reccive data to controller i am not able to access it outside that function 
$scope.resource return data inside function but not outside please help.
var app = angular.module('app', ['ui.router','ngTasty']);
app.config(['$urlRouterProvider', '$stateProvider',function($urlRouterProvider, $stateProvider, $routeProvider, $locationProvider) {
    $urlRouterProvider.otherwise('/');
    $stateProvider
        .state('home', {
            url: '/',
            templateUrl: 'templates/home.html',
            controller: function($scope, $http, $location, agrService) {
                agrService.bannerSlides().then(function(data) {
                    //its working here                       
                   $scope.resource = data;
                }, function(error) {
                    // do something else
                });
I NEED TO ACCCESS DATA HERE CAN ANY BODY HELP
               console.log($scope.resource);
            }
        });
}]);
app.service('agrService', function($q, $http) {this.bannerSlides = function() {
        var dataUrl = 'http://WWW.EXP.COM/codeIgniter_ver/main/home';
        var ret = $q.defer();
        $http({
                method: 'GET',
                dataType: "json",
                url: dataUrl
            })
            .success(function(data, status, headers, config) {
                ret.resolve(data);
            }).error(function(data, status, headers, config) {
                ret.reject("Niente, Nada, Caput");
            });
        return ret.promise;
    };
});
 
     
     
     
    