我正在尝试实现ngbTypeAhead,但是使用5.5.5版本时RxJS出现了问题。我已经从rxjs 6版本中获取了这个示例。
"rxjs": "^5.5.2" and
angular "^5.0.1",
"typescript": "~2.6.1",
当我尝试在焦点上提前输入时,出现类似的错误,
*[ts] Property 'pipe' does not exist on type 'UnaryFunction<Observable<{}>, Observable<string | {}>>'.
any*
search2 = (text$: Observable<string>) => {
const debouncedText$ = text$.pipe(debounceTime(200), distinctUntilChanged());
const clicksWithClosedPopup$ = this.click$.pipe(filter(() => !this.instance.isPopupOpen()));
const inputFocus$ = this.focus$;
let mer = merge(debouncedText$, inputFocus$, clicksWithClosedPopup$);
debugger;
return mer.pipe(
map(term => (term === '' ? this.roadList
: this.roadList.filter(v => v.toLowerCase().indexOf(term.toString().toLowerCase()) > -1)).slice(0, 10))
);
}
谁能帮我解决这个问题,如何重写上面的search2方法?
您最有可能merge
希望merge
以所谓的“可观察的创建方法”并直接以形式导入为运算符'rxjs'
。
因此,请检查您是否真的在RxJS 6中使用此导入:
import { merge } from 'rxjs';
...而不是merge
您不需要的导入操作符:
import { merge } from 'rxjs/operators'; // This imports just the operator
对于RxJS 5,请使用以下命令:
import { merge } from 'rxjs/observable/merge';
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句