'Observable <object>'类型中不存在属性'concatMap'?

时间:2018-01-16 17:11:56

标签: angular rxjs5

我从Angular 4升级到5,并将Http替换为HttpClient。我从http.post调用中移除了链接地图,该调用现在返回Observable<Object>,但在我的组件中,它现在正在抱怨concatMap does not exist on type Observable<Object>。以下是我正在做的一个例子:

//service
import { HttpClient} from '@angular/common/http';

constructor(private _http: HttpClient) { }

registerDomain()
{

return this._http.post('/api/domain/domain/register', {});
}

//component
registerDomain(caseId,domain) {
    return this._domainService.registerDomain(caseId,domain)
      .concatMap(operation => this.getOperationDetail(operation.OperationId,this.caseId,domain))
      .concatMap(() => this.createRecordSets(domain));
  }

我可以在Observable<Object>上看到地图和mergeMap,但不能看到concatMap

2 个答案:

答案 0 :(得分:6)

尝试导入:

import 'rxjs/add/operator/concatMap'

答案 1 :(得分:3)

您需要使用管道

registerDomain(caseId,domain) {
    return this._domainService.registerDomain(caseId,domain)
      .pipe(
         concatMap(operation => this.getOperationDetail(operation.OperationId,this.caseId,domain))
         concatMap(() => this.createRecordSets(domain))
    );
  }