I am starting with AngularJS and I am having some problems trying to use a factory from a controller.
I have the following factory
angular.module('testingApp') .factory('factoryService', function ($http) { // Service logic var getSpec = function(p) { return $http.get('http://someurl//?p=' + p); }; return { getSpec: getSpec }; });
and then I will try to use it from the controller as follows
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); }); }]);
But when I try to run it, I get the following message
TypeError: Cannot read property 'getSpec' of undefined
I donβt know what I donβt have, it should be a newbbie error, I googled, and I tried many examples with the same result.
Any ideas on what I'm doing wrong?
Thanks!
source share