我使用的是ng-选择v2和角7。
在下面的返回语句中有一个错误
getHospital(term: string = null): Observable<Hospitals[]> {
let items = this.getHospitals1();
if (term) {
items = items.pipe(
filter((x,i) => x[i].name.toLocaleLowerCase().indexOf(term.toLocaleLowerCase()) > -1)
)
}
return of(items).pipe(delay(500));
}三个错误,上面写着:
这是我的getHospitals1函数
getHospitals1() : Observable<Hospitals[]>{
return this.http.get<Hospitals[]>('https://my-json-server.typicode.com/monsterbrain/FakeJsonServer/hospitals')
}
export interface Hospitals {
id: string;
name: string;
address: string;
}应该修改什么来解决这个问题呢?
发布于 2018-11-20 12:14:03
您面临的问题是行return of(items).pipe(delay(500)); --在使用of函数时,它将您的Observable<any[]>转换为Observable<Observable<any[]>。只要把电流输送到可以观察到的延迟,你就可以走了。
return items.pipe(delay(500));https://stackoverflow.com/questions/53392647
复制相似问题