title: How do I create a custom object class that's available to my methods in AngularJS
body: <p>I'm a huge fan of angular but it's got some tricky concepts with extremely nuanced differences between them and this is one of them. </p>
  
  <p>I just want to create an class that I can use to create custom objects in my Angular controllers and factories. It surely shouldn't be that hard but I can't figure out how to do it. I want to have a custom, ResultSet class which I can instantiate to create instances of ResultSet. However for the life of me I can't figure out the correct syntax of factory v. service to use.</p>
  
  <p>This is <em>all</em> I want:</p>
  
  <pre><code>ResultSet = function(dataSet){ 
    this.filter = function(){ 
      # filters and returns dataSet
      # ...
    }
  }
  </code></pre>
  
  <p>and then I want to be able instantiate an instance of ResultSet inside a controller etc:</p>
  
  <pre><code>MyApp.controller('pageCtrl', ['ResultSet',  (ResultSet) -&gt;
    # ...
    rs = ResultSet.new(dataToFilter)
  </code></pre>
  
  <h2>How can I create a service that allows me to create instances of my custom object?</h2>
  
  <p>It seems more correct to use an Angular Service rather than a Factory since a service returns an instance of an object (which is exactly what I want). But I can't figure out how to do this...</p>
  
  <p>How would I use a service to declare my custom <code>ResultSet</code> class and then how would I instantiate an instance from it?</p>