title: AngularJS - Factory - TypeError: Cannot read property 'getSpec' of undefined
body: <p>I am starting with AngularJS and i am having some issues when trying to use a factory from a controller.</p>
  
  <p>I have the following factory</p>
  
  <pre><code>angular.module('testingApp')
    .factory('factoryService', function ($http) {
      // Service logic
      var getSpec = function(p) {
        return $http.get('http://someurl//?p=' + p);
      };
      return {
        getSpec: getSpec  
      };
    });
  </code></pre>
  
  <p>and then i try to consume it from the controller as follows</p>
  
  <pre><code>angular.module('testingApp')
    .controller('ServiceincientsCtrl',[ function (factoryService,$scope) {
     console.log('Starting Service Incident Controller');
      factoryService.getSpec('AAA').then(function(response){
          $scope.result = response.data;
      }, function(error){
          console.log('opsssss' + error);
      });
  
    }]);
  </code></pre>
  
  <p>But when i try to run it i receive the following message</p>
  
  <pre><code>TypeError: Cannot read property 'getSpec' of undefined
  </code></pre>
  
  <p>I don't know what i am missing,It should be a newbbie error,  I googled it and i tried many examples with the same result.</p>
  
  <p>Any ideas of what i am doing wrong?</p>
  
  <p>Thanks!</p>