Angularjs 装饰$http时出错

Angularjs 装饰$http时出错,angularjs,http,decorator,angular-decorator,Angularjs,Http,Decorator,Angular Decorator,我正在尝试实现一个简单的$http.get()修饰符。调用get()后,我希望将返回承诺传递给我自己的服务ProgressBar。(我的服务在控制器FWIW中运行良好。) $provide.decorator('$http',函数($delegate,ProgressBar){ //得到 var tempGet=$delegate.get; $delegate.get=function(){ var args=Array.prototype.slice.apply(参数) var httpPro

我正在尝试实现一个简单的$http.get()修饰符。调用get()后,我希望将返回承诺传递给我自己的服务ProgressBar。(我的服务在控制器FWIW中运行良好。)

$provide.decorator('$http',函数($delegate,ProgressBar){
//得到
var tempGet=$delegate.get;
$delegate.get=function(){
var args=Array.prototype.slice.apply(参数)
var httpPromise=tempGet.apply(未定义,参数);/(参数[0],参数[1]);
InProgressBar.inProgressAsync(httpPromise);
};
返回$delegate;
});
然而,我得到以下错误

Error: undefined is not an object (evaluating '$http.get(tpl, httpOptions)
        ['finally']')
handleRequestFn@http://localhost:9000/bower_components/angular/angular.js:17554:41
ngIncludeWatchAction@http://localhost:9000/bower_components/angular/angular.js:24143:29
constantListener@http://localhost:9000/bower_components/angular/angular.js:14276:25
$digest@http://localhost:9000/bower_components/angular/angular.js:15715:31
$apply@http://localhost:9000/bower_components/angular/angular.js:15986:31
bootstrapApply@http://localhost:9000/bower_components/angular/angular.js:1658:21
invoke@http://localhost:9000/bower_components/angular/angular.js:4473:22
doBootstrap@http://localhost:9000/bower_components/angular/angular.js:1656:20
bootstrap@http://localhost:9000/bower_components/angular/angular.js:1676:23
angularInit@http://localhost:9000/bower_components/angular/angular.js:1570:14
http://localhost:9000/bower_components/angular/angular.js:28683:16
fire@http://localhost:9000/bower_components/jquery/dist/jquery.js:3148:35
fireWith@http://localhost:9000/bower_components/jquery/dist/jquery.js:3260:11
ready@http://localhost:9000/bower_components/jquery/dist/jquery.js:3472:24
completed@http://localhost:9000/bower_components/jquery/dist/jquery.js:3503:15

我想(?)我正在错误地格式化http请求,但我看不出是怎么回事。任何想法。谢谢。

看起来您正在覆盖
$http.get
,但没有返回任何内容。尝试在
$delegate.get
method.Ugh中返回
httpPromise
。我一定累了。添加“返回httpPromise;”修正了错误。非常感谢。如果你想要答案,把你的评论变成答案,我会接受。