抱歉,所有的评论垃圾邮件。我想我找到了你问题的答案。
你必须附加
Directive
在定义decorator时指向一个指令:
function coreConfig($provide) {
$provide.decorator('uibCarouselDirective', function ($delegate) {
console.log($delegate[0]);
$delegate[0].templateUrl = 'bootstrap/carousel/carousel.html';
return $delegate;
});
};
从文档中:
对于不同的服务,装饰者有不同的规则。这是
因为服务是以不同的方式注册的。服务是
按名称选择,但是筛选和指令由
在名称末尾附加“filter”或“directive”。这个
提供的$delegate由服务类型决定。
https://docs.angularjs.org/guide/decorators
这是我自己(工作)代码中的一个示例:
$provide.decorator("uibDatepickerPopupDirective", [
"$delegate",
function($delegate) {
var directive = $delegate[0];
// removed for brevity
return $delegate;
}
]);