話不多說,在我的controller中我打印一下我的service foo,當(dāng)我沒有在 config中使用 如下代碼時 $provide.decorator('foo',function($delegate){
$delegate.greet = function(){ return "Hello, I am a new function of 'foo'";
}
});這個foo服務(wù)代碼是;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
};
}
};
}])當(dāng)我不適用修飾器時,在controller中注入foo,是可以打印并且正常使用的,但是當(dāng)我在 app.config中使用修飾器時,打印foo顯示undefined,介是為嘛呢?這個例子來自http://www.html-js.com/articl...
關(guān)于angularjs $provide的decorator函數(shù)使用報錯。
繁星coding
2018-09-07 09:09:37