How can I extend the constructor of an AngularJS resource ($resource)?
问题 I have a model, defined using $resource , that I am successfully loading. Each loaded instance is, as promised, an instance of the class I defined. (The example below is from the Angular docs. In it, User.get results in an object that is an instanceof User .) var User = $resource('/user/:userId', {userId:'@id'}); However, imagine each User comes over the wire like this: { "username": "Bob", "preferences": [ { "id": 1, "title": "foo", "value": false } ] } I defined a Preference factory that