Why is my Angular services saying “undefined is not a function” when I pass my function

I am trying to write a factory and two constructor patterns into Angular. I want the factory to be an Angular service.

So I have some code which (very basically) looks like this:

function processFactory () {
     // some code...

angular.service('processFactory', processFactory);

But the last line gives me an error reading undefined is not a function.

Full code here


check out what I did here: http://jsfiddle.net/Hw7a2/2/

   var app = angular.module('app', ['processFactory']);


   app.service('processFactory', processFactory);

You need to register the service on the module not on the angular object.

Leave a Reply

Your email address will not be published. Required fields are marked *