title: Create injectable class (constructor)
body: <p>I'm an AngularJS newbie, and I'm just starting to understand the concepts and differences of <code>factory</code>, <code>service</code> and <code>controller</code>. As I understand, a <code>factory</code> is used to return a "value object" that can be injected. Most examples I've seen do something like this:</p>
  
  <pre><code>angular.module('module.factories', function() {
      factory('FactoryObject', function() {
          return {
              someFunction: function(someParam) {};
              someOtherFunction: function(someOtherParam) {});
          };
      });
  });
  </code></pre>
  
  <p>In my <code>controller</code>, I want to be able to use this object, but I would like to initialize/instantiate it in the controller, since it can be re-initialized depending on events/actions in the controller. Therefore, I was wondering if I could return a constructor function in the factory instead? </p>
  
  <pre><code>angular.module('module.factories', function() {
      factory('FactoryObject', function() {
  
          function FactoryObject(initParam) {
          }
  
          FactoryObject.prototype.someFunction = function() {};
  
          return FactoryObject;
  
      });
  });
  </code></pre>
  
  <p>Is this a suitable pattern for an angular factory? Or is it just "overkill" to use a factory for a custom object like this? Should I just include it in a library js file and reference it from there instead? One benefit of putting it in a factory is that it will be easy to mock it in a test since it will be injected where it's used. Are there any other mechanisms in Angular that could be used instead?</p>