我正在嘗試使用 observables (rxjs 6.5.1) 在 Angular 9 的頂級組件上加載頁面數據。當我單獨訂閱這些服務中的每一項時,我可以看到返回的數據很好:ngOnInit(): void { const technicianSubscription = this.techniciansClientService.getByTechnicianId(this.technicianId).subscribe(technician => console.log(technician)); const technicianReviewsSubscription = this.technicianReviewsClientService.getByTechnicianId(this.technicianId).subscribe(technicianReviews => console.log(technicianReviews));}當我嘗試使用 forkJoin 時,從未返回訂閱方法中的數據:ngOnInit(): void { this.pageDataSubscription = forkJoin({ technician: this.techniciansClientService.getByTechnicianId(this.technicianId), technicianReviews: this.technicianReviewsClientService.getByTechnicianId(this.technicianId), }).subscribe( // data is never logged here data => console.log(data) );}我試過傳遞 forkJoin 一系列服務調用,我也試過使用 zip,但無濟于事。這里發生了什么事?
Angular 9:forkJoin 訂閱不工作
慕蓋茨4494581
2023-02-17 11:05:16