0
私は、HTTPリクエストがあります。httpリクエストを変換する/成功した場合に関数を追加する。 ::活字&Angular2
private getValues() {
this._watchlistElements.map(v =>
this.http.get('http://localhost/getValue/' + v.xid)
.subscribe(res => {
this._values.push(res.json());
}));
};
をし、成功の場合には、私は1行のコードにしたい:
this.vars.map((v,i) => v.push(this._values[i].value));
を私の質問は通常のアヤックスでそれはのようになります.success: function(){}
私のコードをt彼の?
ありがとうございます。
EDIT
private getValues() {
this._watchlistElements.map(v =>
this.http.get('http://localhost/getValue/' + v.xid)
.subscribe(res => {
this._values.push(res.json());
})).then(console.log());
};
Angular2がthen
変数を解決することができません。コンポーネントをインポートするにはどうすれば機能するのですか?
角度の$ HTTPのみを使用したい場合は
は約束をサポートしています。あなたのアプローチは、$ http.get(url).then(successFunction).catch(errorFunction); – fubbe
@fubbeありがとうございます、完全な回答をしたいですか? –