Angularjs 如何合并多个订阅 ngOnInit(){ this.getSubsidersByAppUserId(this.appUserId); this.getHistoricalRecordsBySerid(this.appUserId); } GetSubsidersByAppUserId(id){ this.appUserService.findByReportTo(id) .subscribe((appUserResponse:HttpResponse)=>{ this.substances=appUserResponse.body; }); } GetHistoricalRecordsBySerId(id){ this.jobPostingService.findHistoricalRecById(id) .订阅((jobPostingResponse:HttpResponse)=>{ this.historyRec=jobPostingResponse.body; console.log(“test>>”+this.historyRec.length); //log(“test>>”+JSON.stringify(this.client)); }); }
我在运行此代码时遇到问题,因为.subscribe无法立即获取2个数据。有什么简单的方法可以克服这个问题吗?在调整代码时会出现什么错误,请给出示例输出,以便用户能够轻松地提供帮助-目标是什么?为什么“立即”需要两组数据?Angularjs 如何合并多个订阅 ngOnInit(){ this.getSubsidersByAppUserId(this.appUserId); this.getHistoricalRecordsBySerid(this.appUserId); } GetSubsidersByAppUserId(id){ this.appUserService.findByReportTo(id) .subscribe((appUserResponse:HttpResponse)=>{ this.substances=appUserResponse.body; }); } GetHistoricalRecordsBySerId(id){ this.jobPostingService.findHistoricalRecById(id) .订阅((jobPostingResponse:HttpResponse)=>{ this.historyRec=jobPostingResponse.body; console.log(“test>>”+this.historyRec.length); //log(“test>>”+JSON.stringify(this.client)); }); },angularjs,Angularjs,我在运行此代码时遇到问题,因为.subscribe无法立即获取2个数据。有什么简单的方法可以克服这个问题吗?在调整代码时会出现什么错误,请给出示例输出,以便用户能够轻松地提供帮助-目标是什么?为什么“立即”需要两组数据? ngOnInit() { this.getSubordinatesByAppUserId(this.appUserId); this.getHistoricalRecordsByUserId(this.appUserId); } getSub
ngOnInit() {
this.getSubordinatesByAppUserId(this.appUserId);
this.getHistoricalRecordsByUserId(this.appUserId);
}
getSubordinatesByAppUserId(id) {
this.appUserService.findByReportTo(id)
.subscribe((appUserResponse: HttpResponse<AppUser[]>) => {
this.subordinates = appUserResponse.body;
});
}
getHistoricalRecordsByUserId(id){
this.jobPostingService.findHistoricalRecById(id)
.subscribe((jobPostingResponse: HttpResponse<JobPosting[]>) => {
this.historyRec = jobPostingResponse.body;
console.log("test >>"+this.historyRec.length);
// console.log("test >>"+JSON.stringify(this.client));
});
}