【发布时间】:2016-03-29 16:47:49
【问题描述】:
我来自 Angular1,并且像链接承诺一样,我希望有类似的行为。
我在 someclass 中有一个方法:-
{.........
doLogin (username, password) {
.......
.......
return this.http.get(api).subscribe(
data => {.....}, //enters here
err => {.....}
}
然后我调用这个方法:-
someclass.doLogin(username, password).subscribe(
data => { }, //Not getting called
err => { }
}
正如我在上述代码中作为 cmets 所提到的,订阅不会在调用者类中被调用。
关于如何做到这一点的任何建议?
【问题讨论】: