title: AngularJS: Creating Objects that map to REST Resources (ORM-Style)
body: <p>I'm pretty new to AngularJS, but I'm pretty unclear on how to tie it up to my Server's REST Api backend.</p>
  
  <p>For example, say I have an "image" resource that I get by GET-ing: myApi/image/1/. This returns a json object with various fields. Let's say something like:</p>
  
  <pre><code>{url: "some/url", date_created: 1235845}
  </code></pre>
  
  <p>Now, I want some kind of representation in my AngularJS app of this "Image" object. This representation is more than just a mapping of the fields - I want to add "helper" functions, for example a function that converts the <code>date_create</code> field into something human-readable.</p>
  
  <p>I know about the $resource service, but I'm unclear what I need to do to create a basic "class" in Angular, that uses Resource to get the JSON object, but then enhances it by adding various helper functions.</p>
  
  <p><strong>Bonus points:</strong> </p>
  
  <p>I'm also unclear how to add "relationships" between models. For example, I might have a "user" resource that has embedded inside it an "image" resource, and I'll want to grab the User resource, but be able to call "Image" helper functions on the "Image" part of the model.</p>