話不多說,在我的controller中我打印一下我的service foo,當我沒有在 config中使用 如下代碼時 $provide.decorator('foo',function($delegate){
$delegate.greet = function(){ return "Hello, I am a new function of 'foo'";
}
});這個foo服務代碼是;appService.provider('foo', [function () { var thisIsPrivate = "Private"; return {
setPrivate: function(newVal) {
thisIsPrivate = newVal;
},
$get: function() { function getPrivate() { return thisIsPrivate;
} return {
variable: "This is public",
getPrivate: getPrivate
};
}
};
}])當我不適用修飾器時,在controller中注入foo,是可以打印并且正常使用的,但是當我在 app.config中使用修飾器時,打印foo顯示undefined,介是為嘛呢?這個例子來自http://www.html-js.com/articl...
關于angularjs $provide的decorator函數使用報錯。
繁星coding
2018-09-07 09:09:37