提前输入:Observable.create(...)。mergeMap不是一个函数

时间:2018-10-20 14:37:58

标签: angular ngx-bootstrap angular7

我正在使用ngx-bootstrap 3.0.1,并将应用程序从Angular 6.1.3升级到7.0.0,并出现错误 mergeMap不是函数

  

CfComponent_Host.ngfactory.js? [sm]:1错误,TypeError:   rxjs_Observable__WEBPACK_IMPORTED_MODULE_4 __。Observable.create(...)。mergeMap   不是功能

使用的代码如下:

import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/mergeMap';
import { TypeaheadMatch } from 'ngx-bootstrap/typeahead';
................
 this.dsTA = Observable.create((observer: any) => {
        observer.next(this.cl.TA);
      }).mergeMap((token: string) => this.getAsObservTA(token));

使用角度为6.1.3的代码有效

older:“ rxjs”:“ ^ 6.2.2”,“ rxjs-compat”:“ ^ 6.1.0”, 新增:“ rxjs”:“ ^ 6.3.3”,“ rxjs-compat”:“ ^ 6.3.3”

Angular CLI: 7.0.2
Node: 10.12.0
OS: win32 x64
Angular: 7.0.0
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, platform-server, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.9.0-rc.3
@angular-devkit/build-angular     0.9.0-rc.3
@angular-devkit/build-optimizer   0.9.0-rc.3
@angular-devkit/build-webpack     0.9.0-rc.3
@angular-devkit/core              7.0.0-rc.3
@angular-devkit/schematics        7.0.2
@angular/cdk                      6.4.7
@angular/cli                      7.0.2
@ngtools/webpack                  7.0.0-rc.3
@schematics/angular               7.0.2
@schematics/update                0.10.2
rxjs                              6.3.3
typescript                        3.1.3
webpack                           4.21.0

感谢任何线索

1 个答案:

答案 0 :(得分:3)

RxJs在版本> = 6.0.0中已更改

下面是使代码正常工作所需要做的事情。

import { mergeMap } from 'rxjs/operators';

................
 this.dsTA = Observable.create((observer: any) => {
        observer.next(this.cl.TA);
      }).pipe(mergeMap((token: string) => this.getAsObservTA(token)));

请查看以下网址,以详细了解迁移情况

https://github.com/ReactiveX/rxjs/blob/master/docs_app/content/guide/v6/migration.md