services.js
.service('emailService', function() {
this.email = "give me!";
this.setContent = function(content) {
this.email = content;
};
this.send = function(recipient) {
return 'sending "' + this.email + '" to ' + recipient;
};
})
app.js
.config(function($provide){
$provide.decorator('emailService',function($delegate){
$delegate.sendWithSignature=function(recipient,email){
return 'sending "'+this.email+'" to '+recipient+" by "+email
}
return $delegate
})
})
controller.js
$scope.resole = emailService.sendWithSignature("lin", "how are you !");
alert($scope.resole);