Javascript 正在尝试使用{timeout:canceler.promise}取消$http请求

Javascript 正在尝试使用{timeout:canceler.promise}取消$http请求,javascript,angularjs,http,Javascript,Angularjs,Http,我需要一些帮助来调试为什么根据Chrome开发工具将timeout属性作为{}传递 function request(options) { let canceller = this.$q.defer(); if (this.canceller) { console.error('CANCELLING EARLIER REQUEST', this.canceller); this.canceller.resolve(); } o

我需要一些帮助来调试为什么根据Chrome开发工具将timeout属性作为{}传递

function request(options) {

    let canceller = this.$q.defer();

    if (this.canceller) {
        console.error('CANCELLING EARLIER REQUEST', this.canceller);
        this.canceller.resolve();
    }

    options.timeout = this.canceller.promise;

    console.warn('options =', options);
    console.warn('Submitting request : :: : ::);

    this.$http.post(url, options)
        .then( resp => {

            console.warn('Request complete!');
            this.canceller = null;
        });
}  
我不知道如何创建一个测试环境,但是如果您两次启动这个函数,console.logs将如何运行

options Object {timeout: Promise}
Submitting request : :: : ::
CANCELLING EARLIER REQUEST Deferred {promise: Promise}   //second request fired
options Object {timeout: Promise} 
Submitting Request : :: : ::
Request Complete!                    //this is the first request
Request Complete!                    //this is the second request

以下是我在每个请求的“网络”选项卡中看到的内容:

Request payload:

{
    timeout: {}
}

注意,超时是一个空对象-这就是为什么我的第二个请求没有取消第一个请求的原因吗?我的应用程序中是否有一个$httpProvider正在清除参数?

不清楚这是如何工作的。什么是
params
?什么是格式化程序?整件事只是分崩离析,遗漏了必要的细节。请提供。@estus感谢您的评论。我简化了这个例子。不明显的是,
这个
在两个请求中引用了相同的对象<代码>此。取消器未分配给延迟的。一个可以复制这个问题的plunk会很有帮助。