title: How to get an ajax result to a controller in Angular?
body: <p>I have a service which get the value from my ajax call. I want to store that value in a variable and pass that variable to the controller.</p>
  
  <pre class="lang-js prettyprint-override"><code>angular.module("Data", []).service("DataService", function($http) {
    return {
      Data: function(callback) {
        $http.get('http://www.w3schools.com/angular/customers.php').success(callback);
      }
    }
  })
  
  angular.module("Home", ["Data"]).service("HomeService", function(DataService) {
    var customerData = {}
    return {
      Getdata: DataService.getCustomers(function(results) {
        customerData = results;
        console.log(customerData)
      })
    }
  })
  
  
  angular.module("Home").controller("HomeCntrl", function($scope, HomeService) {
  
    $scope.Result = HomeService.Getdata;
  
  })
  </code></pre>
  
  <p>I want the data to be stored in <code>customerData</code> and I have to pass <code>customerData</code> to the controller.</p>