Improve this Doc

Error: $injector:undef
Undefined Value

Provider '{0}' must return a value from $get factory method.

Description

This error results from registering a factory which does not return a value (or whose return value is undefined).

The following is an example of a factory which will throw this error upon injection:

angular.module("badModule", []).
factory("badFactory", function() {
  doLotsOfThings();
  butDontReturnAValue();
});

In order to prevent the error, return a value of some sort, such as an object which exposes an API for working with the injected object.

angular.module("goodModule", []).
factory("goodFactory", function() {
  doLotsOfThings();
  butDontReturnAValue();

  return {
      doTheThing: function methodThatDoesAThing() {
      }
  };
});