Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/29.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-Filter显示为筛选,但结果仍然显示未筛选_Angular_Rxjs_Angular Material - Fatal编程技术网

Angular RXJS-Filter显示为筛选,但结果仍然显示未筛选

Angular RXJS-Filter显示为筛选,但结果仍然显示未筛选,angular,rxjs,angular-material,Angular,Rxjs,Angular Material,我使用的是RXJS 6.3.3 我有以下代码可以过滤掉已经选择的小控件 因此,如果我有: Gizmos = "Red", "Blue", "Green" 用户选择“蓝色” 我应该只看到“红色”和“绿色”作为可用选项 然而,我仍然看到“红”、“蓝”、“绿” 在“调试”中,过滤器似乎正在运行,它将打印以下示例: Red:true Blue:false Green:true 我不确定我遗漏了什么,因为UI仍然显示所有3个值 <mat-autocomplete #auto="mat

我使用的是RXJS 6.3.3

我有以下代码可以过滤掉已经选择的小控件

因此,如果我有:

Gizmos = "Red", "Blue", "Green"
用户选择“蓝色”

我应该只看到“红色”和“绿色”作为可用选项

然而,我仍然看到“红”、“蓝”、“绿”

在“调试”中,过滤器似乎正在运行,它将打印以下示例:

Red:true Blue:false Green:true
我不确定我遗漏了什么,因为UI仍然显示所有3个值

      <mat-autocomplete #auto="matAutocomplete" (optionSelected)="selected($event)">
        <mat-option *ngFor="let gizmp of filterGizmos | async" [value]="gizmo.value" (onSelectionChange)="gizmoSelectionChange(gizmo)">
          {{gizmo.value}}
        </mat-option>
      </mat-autocomplete>



   filterGizmos: Observable<Gizmo[]>;
   this.filterGizmos = this.filterGizmoData(this.searchTerm.value); 

   filterGizmoData(searchString?: string): Observable<Gizmo[]> {
    let tfp = new GizmoFindParameters();

    if (searchString == undefined) {
      tfp.value = "";
    } else {
      tfp.value = searchString.trim();
    }

    return this.gizmoService.find<Gizmo[]>(tfp)
      .pipe(tap(x =>
        x.filter((y) => {
          console.log(y.value);
          console.log(!this.selectedGizmos.includes(y.value)); 
          return !this.selectedGizmos.includes(y.value);
        })
      )
      );
  };

{{gizmo.value}
filterGizmos:可观察的;
this.filterGizmos=this.filterGizmoData(this.searchTerm.value);
filterGizmoData(searchString?:string):可观察{
设tfp=new GizmoFindParameters();
if(searchString==未定义){
tfp.value=“”;
}否则{
tfp.value=searchString.trim();
}
返回此.gizmoService.find(tfp)
.管道(水龙头(x=>
x、 过滤器((y)=>{
控制台日志(y值);
console.log(!this.selectedGizmos.includes(y.value));
return!this.selectedGizmos.includes(y.value);
})
)
);
};

点击
不会修改流。它通常用于调试和副作用(不影响流的操作)

改用
map

这来自
点击
的文档:

对可观察到的源上的每个发射执行副作用,但是 返回与源相同的可观测值


谢谢你。我没听懂