I am currently trying to realize my own promise, which will be used inside Angular 2. If I reject promise, I will get Error: Uncaught (in promise): nope(…) , but only on the first promise that will be rejected.
This is Angular 2.0.0-rc.4 , but I noticed this in other behaviors. My question is, is this a mistake in my understanding of Promises, or is this a bug that should be reported in the Angular project?
Code example:
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");
Console (Google Chrome 51.0.2704.106, Linux 64 bit):
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(…)
source share