1、将定义的服务内容修改
2、修改完后必须返回
3、在angular1.4以上才出现
4、不能装饰constant服务
5、语法:
app.decorator('已有的服务名',function($delegate){
xx
return xxx;
})
其中:
$delegate代表服务的内容
代码示例:
var app=new angular.module('app',[]);
app.controller('main',['$scope',function($scope){
$scope.msg='哈哈';
}])
app.factory('ssr',function(){
return {
a:12,
b:15
}
})
app.decorator('ssr',function($delegate){
$delegate.a=12
return $delegate;
})
app.controller('d1',['$scope','ssr',function($scope,ssr){
console.log(ssr);
}])