title: Angularjs $http.get in a factory doesn't return valid JSON but a different object
body: <p>When I call <code>$http.get</code> from a factory it doesn't return the JSON object I need but a different one.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>var cart = angular.module('cart', []);
  
  cart.factory('getItems',['$http', function($http){
      return{ 
          get:$http.get('index.php').
              success(function(data){
                  return data;
              })
          }
  }]);
  
  
  cart.controller("TableCtrl", ['$scope', 'getItems', function($scope, getItems){
      console.log(getItems.get);
  }]);
  </code></pre>
  
  <p>now this is the JSON object that it should return:</p>
  
  <pre><code>[{"id":"1","name":"Cap"},{"id":"2","name":"Coat"},{"id":"3","name":"Shoes"}]
  </code></pre>
  
  <p>And this is what I get when I console.log</p>
  
  <pre><code>d {$$state: Object, success: function, error: function, then: function, catch: function…}
  </code></pre>
  
  <p>everything runs fine if I run the <code>$http.get</code> inside the controller, but if I place it in a factory it just doesn't.</p>