Can you help me please to consider where to place resource (service) specific business logic in AngularJS. I feel it should be great to create some model-like abstraction over m
The best place for logic that needs to be invoked on an instance of a domain object would be a prototype of this domain object.
You could write something along those lines:
services.factory('CustomerService', ['$resource', function($resource) {
var CustomerService = $resource('http://virtualmaster.apiary.io/customers/:id', {}, {
all: {
method: 'GET',
params: {}
}
//more custom resources methods go here....
});
CustomerService.prototype.fullName = function(){
return this.first_name + ' ' + this.last_name;
};
//more prototype methods go here....
return CustomerService;
}]);