Closed
Description
I have a user resource and I want to add functionality to it to make things easier to work with. For example, with ngResource
I did something like this:
var User = $resource(BaseUrl + '/api/v1/rest/users/:id', { id: '@_id' });
User.prototype.getDisplayName = function() {
if (this.name.first && this.name.last) {
return (this.name.first || '') + ' ' + (this.name.last || '');
} else if (this.username) {
return '@' + this.username;
} else {
return 'Anonymous';
}
};
So, with the direction that angular-data is going, would you recommend:
- Have a
UserControllerService
or something that would act on the POJO - Hook the lifecycle of the resource (like
afterCreate
) and return a new User(data) version of the POJO?
Looking forward to using this and hopefully providing good feedback and PRs 👍