【发布时间】:2018-06-18 16:09:13
【问题描述】:
您好,我有多个应用程序的全球服务,我希望创建一个具有多个订阅的方法,以便存储和初始化我的所有数据,我希望在我的 appComponent 中订阅此方法,但我不知道如何做到这一点
为我服务
private initData(isLogged: boolean) {
this.http.get('/api/conf').subscribe(
conf => {
this.http.get('api/param').subscribe(
tokResp => {
this.appParams.token = tkResp.queoval;
this.appParams.culture = tkResp.culture;
this.appParams.GMT = tkResp.gmt;
this.http.get('/api/trad').subscribe(
trad => {
this.label = trad
// return an Observable
}
)
}
)
}
)
}
在我的 AppComponent 中
this.service.initData().subscribe(
result => {
this.test = result
}
我怎样才能做到这一点?我在文档中找不到信息。感谢您的帮助。这对我的工作很重要,我花了这么多时间白白研究:(
【问题讨论】:
标签: rxjs observable angular6 subscribe