',angular,rxjs"/>

首页 > 解决方案 > 'MonoTypeOperatorFunction 类型的参数' 不能分配给 'OperatorFunction 类型的参数'

问题描述

我正在使用rxjs/opterators映射into valueChanges,例如:FormControlObservable

options$: Observable<any[]>;

ngOnInit() {
    // update options$ 
    this.options$ = this.inputCtrl.valueChanges.pipe(
      startWith(null),
      map(text => this.filter(text, value))
    )
}

filter(text: string, list: any[]): any[] {
    // set text in lowerCase for comparison
    text = text.substr(index).trim().toLowerCase();
    // filter list based on text
    return list.filter(item => item.trim().toLowerCase().indexOf(text) !== -1);
}

但我不断收到此错误:

Argument of type 'MonoTypeOperatorFunction<any>' is not assignable to parameter of type 'OperatorFunction<any, any>'.
Types of parameters 'source' and 'source' are incompatible.

我搜索解决方案,我发现了这个问题,但它对我不起作用,因为我已经从 导入运算符rxjs/operators,例如:

import { startWith, map } from 'rxjs/operators';

问题是什么?我该如何解决?

更新:

我第一个操作员收到此错误startWith,我试图将其删除,但后来我得到了它map

标签: angularrxjs

解决方案


推荐阅读