属性“ forkJoin”在类型“ typeof Observable”上不存在

时间:2018-07-10 07:29:06

标签: 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/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)
    }
    }

1 个答案:

答案 0 :(得分:1)

正确的导入为import 'rxjs/add/observable/forkJoin';。注意add

相关问题