So I have a services.js
that looks something like this.
.factory('User', function($resource) {
return $resource('/api/users/:id/', {'id': '@id'}, {
groups: {
method: 'GET',
url: '/api/users/:id/groups',
isArray: true
}
});
})
.factory('Group', function($resource) {
return $resource('/api/groups/:id/', {'id': '@id'}, {
update: {
method: 'PUT'
}
});
})
Users in the db have an implicit relationship to Groups via a JSONField of ids (implicit in that it is not an explicit one2m or m2m). I have a custom endpoint on my api server '/api/users/:id/groups'
that returns a serialized array of Group instances. My issue is that the User::groups
action on the angular side is returning an array of the Group instances BUT with the actions of the USER resource instead of the GROUP resource. Is there any way for the custom action of a $resource to return an instance of a $resource from a different class?
Thanks!