我正在将应用程序从Angular 4升级到Angular 5,并在服务中包含以下代码
loadRefData(): Observable<RefData> {
return this.participant$.switchMap((role) => {
return this.http.get(`${this.API_URL}/${role}/participantGroups/refdata`)
.map(refData => refData as RefData);
});
由于Angular 5满足RxJS 5.5.2的最低要求,我将其转换为使用带有 .pipe()
运算符的lettable运算符 .
我以为我能做到这一点
loadRefData(): Observable<RefData> {
return this.participant$.switchMap((role) => {
return this.http.get(`${this.API_URL}/${role}/participantGroups/refdata`)
.pipe(
map(refData => refData as RefData);
);
});
但我收到错误 TypeError: this.participant$.switchMap is not a function
. 但是我没有从typescript编译器中获得编译错误 .
this.participant$
的类型为 Observable<string>
,除非我弄错了,否则我应该可以执行 switchMap
.
我错过了什么?
这是 typescript@^2.6.1
, rxjs@^5.5.2
.
编辑:我刚刚注意到 ngrx\store.select
填充自 ngrx\store.select
的类型为 Store<string>
.
1 回答
这是来自Angulars博客的报价,可能对你有所帮助 .
资料来源:Angular 5