title: AngularJS - Controller gets the data returned from Service (MVC Web API call) as undefined
body: <p>I am new to AngularJS &amp; working on a sample. In my sample app I have an MVC Web api (which returns some data from db) &amp; it will be called from the Angular Services and returns the data to the Controller. The issue is I am getting the data in my Services success method properly but in my controller it always shows undefined &amp; nothing is displayed in the view. Please see the code below:</p>
  
  <p>My Controller code:</p>
  
  <pre><code>app.controller('CustomerController', function ($scope, customerService) {    
      //Perform the initialization
      init();
  
      function init() {
          $scope.customers= customerService.getCustomers();        
      }   
  });
  </code></pre>
  
  <p>My Services code:</p>
  
  <pre><code>app.service('customerService', function ($http){
         this.getCustomers = function () {
          $http({
              method: 'GET',
              url: 'api/customer'           
          }).
      success(function (data, status, headers, config) {
          return data;
      }).
      error(function (data, status) {
          console.log("Request Failed");
      });
  
      }
  });
  </code></pre>
  
  <p>Please help me to fix this issue.</p>