我现在有一个非常奇怪的问题,我将其简化为最少的代码。我要实现的是过滤可观察到的列表
import { of, Observable } from 'rxjs';
import { filter, map } from 'rxjs/operators';
const list = of([1, 2, 3]);
return list.pipe(
filter(x => x % 2 === 0)
);
我得到一个错误,即x不是数字,而是数字[]
当然,在现实生活中,列表是从后端加载的,并且过滤功能要复杂得多。
rxjs 6.5.4 打字稿3.7.5
答案 0 :(得分:0)
喝了点咖啡后:
const list = of([1, 2, 3]);
return list.pipe(
map(ll => ll.filter(x => x % 2 === 0))
);