title: Angular Service - Return http response
body: <p>I'm trying to build an angular service I can reuse for doing my http requests etc. This all works when it's not in a service.</p>
  
  <p>The following code works and does the login, but the log of $scope.data is always undefined. If i put a log in on the success before I return data it returns the data, but not back to the controller which is what i'm really looking to do.</p>
  
  <p>Just for clarification, I want to be able to access the json data returned from the server as 'data' in the success in my controller.</p>
  
  <p>//App.js</p>
  
  <pre><code>.service('SaveSubmitService', function ($http, $log) {
      this.addItem = function(url, options){
          var xsrf = $.param({
              Username: options.Username,
              Password: options.Password
      });
  
      $http({
          method: 'POST',
          url: url,
          data: xsrf,
          headers: {
              'Content-Type': 'application/x-www-form-urlencoded'
          }
      }).success(function(data, status, headers, config) {
              return data;
  
      }).
          error(function(data, status, headers, config) {
              console.log(data);
              return false;
  
  
     });
      }
  
  })
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>.controller('LoginCtrl', function ($scope, $stateParams, $location, $ionicLoading, $http, SaveSubmitService, $log) {
          if (localStorage.getItem("SessionKey")) {
              $location.path('home');
          }
          $scope.login = {};
          $scope.doLogin = function doLogin() {
  
             $scope.data = SaveSubmitService.addItem('http://*****/Services/Account.asmx/Login', $scope.login);
             $log.info($scope.data);
  
          };
      })
  </code></pre>