title: AngularJS : returning data from service to controller
body: <p>I am trying to create a service to get json and pass it to me homeCtrl I can get the data but when a pass it to my homeCtrl it always returns undefined. Im stuck. </p>
  
  <p>My Service:</p>
  
  <pre><code>var myService = angular.module("xo").factory("myService", ['$http', function($http){
    return{
      getResponders: (function(response){
        $http.get('myUrl').then(function(response){
           console.log("coming from servicejs", response.data);
        });
      })()
    };
    return myService;
    }
  ]);
  </code></pre>
  
  <p>My Home Controller:</p>
  
  <pre><code>var homeCtrl = angular.module("xo").controller("homeCtrl", ["$rootScope", "$scope", "$http", "myService",
  function ($rootScope, $scope, $http, myService) {
   $scope.goData = function(){
       $scope.gotData = myService.getResponders;
   };
   console.log("my service is running", $scope.goData, myService);
  }]);
  </code></pre>