在Angular 2中拒绝Promise时未处理的Promise拒绝

Mar*_* C. 7 promise angular

我目前正在尝试实现我自己的Promise在Angular 2中使用.如果我reject承诺,我会得到一个Error: Uncaught (in promise): nope(…),但只有第一个Promise被拒绝.

它是Angular 2.0.0-rc.4,但我在其他行为中注意到了这一点.我的问题是,这是我对Promises的理解中的错误,还是应该向Angular项目报告的错误?

示例代码:

import {Component} from '@angular/core';
import {bootstrap} from '@angular/platform-browser-dynamic'
@Component({
    template: "TestComponent"
})
class TestComponent {
}
bootstrap(TestComponent, []);

let p = new Promise((resolve, reject) => {
    console.log("create promise");
    reject("nope");
});
console.log("setting up");
p.then(r => console.log("then: " + r));
p.catch(e => console.log("reject: " + e));
console.log("setup done");
Run Code Online (Sandbox Code Playgroud)

控制台(谷歌浏览器51.0.2704.106,Linux 64位):

create promise
setting up
setup done
reject: nope
Angular 2 is running in the development mode. Call enableProdMode() to enable the production mode.
Unhandled Promise rejection: nope ; Zone: <root> ; Task: Promise.then ; Value: nope
Error: Uncaught (in promise): nope(…)
Run Code Online (Sandbox Code Playgroud)

Est*_*ask 11

它应该是

p
.then(r => console.log("then: " + r))
.catch(e => console.log("reject: " + e));
Run Code Online (Sandbox Code Playgroud)

p.then(...)单独创建未处理的链,这困扰Zone.js. 如果您处理过Bluebird的"未处理拒绝",您可能已经知道规则.