In most cases the result of method is an array, which can be easily extended with some methods (business logics) with the follow
This is an old question, but I just ran into this issue myself. gargc's solution is the right approach, but there is an improvement. transformResponse accepts an array that gets passed to the $http service. Rather than completely replace the transform function, you can append your transform to the defaults to just make the updates you need:
angular.module('foo')
.factory('Post', function ($resource, $http) {
var Post = $resource('/api/posts/:id', { id: '@id' }, {
query: {
method: 'GET',
isArray: false,
transformResponse: $http.defaults.transformResponse.concat(function(data, header) {
angular.forEach(data.items, function(item, idx) {
data.items[idx] = new Post(item);
});
return data;
})
}
});
Post.prototype.foo = function() { /* ... */ };
return Post;
});