angular/angular.js — pull request #3051 by sparkio (2013-06-25 07:06:11+00:00)
Title: $resource association / relationships / levels between resources.

Remember that once you have the primary key for one level, you usually don't need to include the levels above because you've already got your specific object. In other words, you shouldn't need too many cases where a URL is deeper than 2 levels deep eg `/resource/identifier/resource`. (http://info.apigee.com/Portals/62317/docs/web%20api.pdf)

However this change will still handle an unlimited amount of associations / relationships / levels if desired and fallback to a single level for $ prefix on returned resource(s).

Example
```javascript
var CreditCard = $resource('/card/:cardId', {cardId:'@id'}, {
charge: {method:'POST', params:{charge:true}}
});
var User = $resource('/user/:userId', {userId:'@id'}, {}, {CreditCard:CreditCard});
var cards = User.CreditCard.query({userId:123}, function() {
// GET: /user/123/card
// server returns: [ {id:456, number:'1234', name:'Smith'} ];

var card = cards[0];
// each item is an instance of CreditCard
expect(card instanceof CreditCard).toEqual(true);
card.name = "J. Smith";
// non GET methods are mapped onto the instances
card.$save();
// POST: /card/456 {id:456, number:'1234', name:'J. Smith'}
// server returns: {id:456, number:'1234', name: 'J. Smith'};

// our custom method is mapped as well.
card.$charge({amount:9.99});
// POST: /card/456?amount=9.99&charge=true {id:456, number:'1234', name:'J. Smith'}
});
```