私は現在、Angular 2内で使用するPromiseを実装しようとしています。reject
という約束があれば、私はError: Uncaught (in promise): nope(…)
を取得しますが、 。PromiseをAngular 2で拒否した場合の未解決のPromise拒否
これはAngular 2.0.0-rc.4
ですが、私はこれを他の動作に気付きました。私の質問は、これが私の約束を理解する上で間違っているのか、これは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");
コンソール(Google Chromeの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(…)
あなたはes6約束を使用していますか、または独自の実装がありますか? – Kliment
私が知る限り、実装は 'zone.js'の' ZoneAwarePromise'です。それが私がAngularに関連していると思う理由です。 –
タイトルは何とか誤解を招くことがあります。 'Angular 2で自らのPromiseを実装する'ことは明白に、自家製Promiseの実装があることを示唆しています。 – estus