title: AngularJS: $resource with nested resources
body: <p>I am using AngularJS $resource model to REST API. I have got something like this:</p>
  
  <pre><code>angular.module('libraryapp')
      .factory('Book', function($resource){
          return $resource('books/:id');
      });
  </code></pre>
  
  <p>I am using in these way:</p>
  
  <pre><code>Book.get({ id: 42 }, function(book) {
      console.log(book);
  });
  </code></pre>
  
  <p>But I also want an endpoint to a subresource, let's say:</p>
  
  <pre><code>GET /books/:id/comments
  </code></pre>
  
  <p>How should I define it in module? May I extend Book in some way, to use it like this</p>
  
  <pre><code>Book.get({ id: 42 }).Comment.query(function(comments) {
      console.log(comments);
  });
  </code></pre>