Angular 财产';forkJoin';不存在于类型';可观察的类型';
我使用的是导入forkJoin的旧语法,我仍然会遇到这个丑陋的错误 它为什么抱怨Angular 财产';forkJoin';不存在于类型';可观察的类型';,angular,fork-join,Angular,Fork Join,我使用的是导入forkJoin的旧语法,我仍然会遇到这个丑陋的错误 它为什么抱怨 import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs/Observable'; import 'rxjs/observable/forkJoin'; import 'rxjs/add
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs/Observable';
import 'rxjs/observable/forkJoin';
import 'rxjs/add/operator/map';
@Injectable()
export class DataService {
apiUrl1: string = 'http://localhost:3000/person/?';
apiUrl2: string = 'http://localhost:3000/facility/?';
apiUrl3: string = 'http://localhost:3000/exposure/?';
constructor(private http: HttpClient) { }
getData(arg): Observable<any> {
return this.http.get(this.apiUrl1 + arg.data)
.flatMap((person: any) => Observable.forkJoin(this.http.get(this.apiUrl2 + person.val1), this.http.get(this.apiUrl3 + person.val2)))
.map(([facility, exposure]) => exposure.val5 * facility.val3)
}
}
从'@angular/core'导入{Injectable};
从'@angular/common/http'导入{HttpClient};
从“rxjs/Observable”导入{Observable};
导入“rxjs/observable/forkJoin”;
导入'rxjs/add/operator/map';
@可注射()
导出类数据服务{
apirl1:string=http://localhost:3000/person/?';
APIRL2:string=http://localhost:3000/facility/?';
APIRL3:string=http://localhost:3000/exposure/?';
构造函数(私有http:HttpClient){}
getData(arg):可观察{
返回this.http.get(this.apirl1+arg.data)
.flatMap((person:any)=>Observable.forkJoin(this.http.get(this.apirl2+person.val1)、this.http.get(this.apirl3+person.val2)))
.map(([facility,exposure])=>exposure.val5*facility.val3)
}
}
正确的导入是导入'rxjs/add/observable/forkJoin'代码>。注意add