enter code here
getHospital(term: string = null): Observable<Hospitals[]> {
let items = this.getHospitals1();
if (term) {
items = items.filter(x => x.name.toLocaleLowerCase().indexOf(term.toLocaleLowerCase()) > -1);
}
return items.pipe(delay(500));;
}
getHospitals1() : Observable<Hospitals[]>{
return this.http.get<Hospitals[]>('https://my-json-server.typicode.com/monsterbrain/FakeJsonServer/hospitals')
}
Here an error occured when i add filter 这是使用ng-select的下拉列表代码 . 它基于基于文本的seraching在这里iam使用angular7和rxjs 6
1 回答
要使用
filter
运算符,您需要在pipe()
中使用它: