Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 为什么RxJS过滤器方法对我不起作用_Angular_Rxjs_Observable_Rxjs5 - Fatal编程技术网

Angular 为什么RxJS过滤器方法对我不起作用

Angular 为什么RxJS过滤器方法对我不起作用,angular,rxjs,observable,rxjs5,Angular,Rxjs,Observable,Rxjs5,在使用RxJS运算符时出现问题 我的端点返回可观察的 我猜这与我定义从DB返回的类型的方式有关。命名Observabe Array.filter() Rxjs.map() Array.filter() Rxjs.map() 您正在访问阵列。您很可能希望使用数组过滤器,查看代码。一个可观测的映射操作符更有意义吗this.reasons$=this.taskService.getTaskReprintReasonCodes().pipe(map(rArray=>rArray.filter(r=

在使用RxJS运算符时出现问题

我的端点返回可观察的

我猜这与我定义从DB返回的类型的方式有关。命名
Observabe

Array.filter()

Rxjs.map()

Array.filter()

Rxjs.map()


您正在访问阵列。您很可能希望使用数组过滤器,查看代码。一个可观测的映射操作符更有意义吗
this.reasons$=this.taskService.getTaskReprintReasonCodes().pipe(map(rArray=>rArray.filter(r=>r.reasonDescription==='New'))
。这就是您不需要知道的吗?看起来你把RxJs中的过滤器和数组中的过滤器混为一谈了。数组生成新的筛选列表,RxJs筛选流并阻止对筛选器无效的项目发出。我可以在我的视频课程中推荐了解有关rxjs6的更多信息:您正在访问数组。您很可能希望使用数组过滤器,查看代码。一个可观测的映射操作符更有意义吗
this.reasons$=this.taskService.getTaskReprintReasonCodes().pipe(map(rArray=>rArray.filter(r=>r.reasonDescription==='New'))
。这就是您不需要知道的吗?看起来你把RxJs中的过滤器和数组中的过滤器混为一谈了。数组生成新的筛选列表,RxJs筛选流并阻止对筛选器无效的项目发出。我可以在我的视频课程中推荐了解有关rxjs6的更多信息:
Observable<Array<TaskReprintReasonCode>>
    this.taskService.getTaskReprintReasonCodes().pipe(
        map((arr:TaskReprintReasonCode[]) => {
             return arr.filter(r => r.reasonDescription === 'New');
        )
    )