2016-07-13 10 views
0

Angular 2のhttp.postを使用してデータを送信し、結果を取得しています。結果が戻ったら、私は関数を実行したいと思いますが、匿名関数は機能しません。これをどのように達成するのですか?TypeScriptで匿名関数を実行するにはどうすればよいですか?

スニペット:

this.http.post("/login/login", this.model) 
    .subscribe(res => function() { 
     console.log('a', this.res); 
    }, 
    error => function (e) { 
     console.log(e); 
    }, 
    () => function() { 
     console.log("3"); 
    }); 

答えて

1

だけ

this.http.post("/login/login", this.model) 
.subscribe(res =>() { 
    console.log('a', this.res); 
}); 
関連する問題