Can virtual attributes be added to ngResource? I created such a service
app.factory('Person', ['$resource', function($resource) { return $resource('api/path/:personId', { personId: '@_id' }, { update: { method: 'PUT' } }); }])
Person has a name attribute and a surname attribute.
I want to extract fullname by adding a virtual fullname attribute that returns resource.name + resource surname .
I know that I can add it to the controller, but adding it to the service, it will make it much more portable. I tried something like this
app.factory('Person', ['$resource', function($resource) { return $resource('api/path/:personId', { personId: '@_id' }, { update: { method: 'PUT' }, fullname: function(resource){ return resource.name + ' ' + resource.surname; } }); }); }])
but that will not work.
angularjs ngresource
pasine
source share