[英]rxjs map method inquire
I'm new to reactive.我是反应式的新手。 I'm trying to map an observable array from a Firebase database but when using the map method, the property should be an any array but it the method ask for any:
我正在尝试从 Firebase 数据库映射一个 observable 数组,但是在使用 map 方法时,该属性应该是一个 any 数组,但该方法要求任何:
ngOnInit () {
this.countries=this.af.database.list('/countries').map(resp=>{
resp.map(...) // <--- not working since resp is not an array
return resp;
})
}
resp should be an array but intellisense marks it as any so I cannot map resp. resp 应该是一个数组,但智能感知将其标记为 any,因此我无法映射 resp。 Has the map methos an overload?
地图方法是否过载?
Usually the response is NOT a json and needs to be parsed first.通常响应不是json,需要先解析。
Something like :就像是 :
this.countries=this.af.database.list('/countries').map(resp=>{
let parsedResp = resp.json();
parsedResp.map(...) // <--- not working since resp is not an array
return parsedResp ;
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.