角度类型错误:Observable.combineLatest不是函数

时间:2018-09-18 04:45:57

标签: angular

Error: Neo4j driver instantiation failed !
Neo4jError: 101057795:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:openssl\ssl\s23_clnt.c:827:

角度版本 TypeError: rxjs_Observable__WEBPACK_IMPORTED_MODULE_3__.Observable.combineLatest is not a function. ,rxjs:6.2.2

我的代码如下:

6.3.2

尝试使用其他文件中提供的ngOnInit() { Observable.combineLatest([ this.route.paramMap, this.route.queryParamMap ]) .switchMap(combined => { let id = combined[0].get('id'); let page = combined[1].get('page'); return this.service.getAll(); }) .subscribe(followers => this.followers = followers); } 请求路径获取followers的列表。

1 个答案:

答案 0 :(得分:2)

combineLatest不是可观察对象的一部分。只需使用combineLatest。另外,将switchMap包装在pipe函数周围

import { combineLatest } from 'rxjs';
import { switchMap } from 'rxjs/operators';

let observerObj = combineLatest([
     this.route.paramMap,
     this.route.queryParamMap
 ]);
observerObj
  .pipe(
    switchMap(combined => {
        let id = combined[0].get('id');
        let page = combined[1].get('page');
        return this.service.getAll();
    })
  ) 
  .subscribe(followers => this.followers = followers);