[英]AngularFire 5: list().valueChanges() does not return anything to subscribe
I'm going to retrieve a list from Firebase using the following code in an Ionic component:我将在 Ionic 组件中使用以下代码从 Firebase 检索列表:
this.afDB.list ( '/my-data/key1/data' ).valueChanges().subscribe ( res => console.log (res), error => console.log (error), () => console.log ("complete") );
if the record exists, it has no problem to print the result.如果记录存在,则打印结果没有问题。 However, if the record does not exist, none of the three callbacks will return.
但是,如果记录不存在,则三个回调都不会返回。 If I replace the list() with object() method, it will simply return null, which is what I need.
如果我用 object() 方法替换 list(),它只会返回 null,这正是我所需要的。 Does anyone know if this is the intent by design of AngularFire 5 or it's a bug?
有谁知道这是 AngularFire 5 的设计意图还是错误?
There is currently a bug in angularfire.目前 angularfire 中存在一个错误。 https://github.com/angular/angularfire2/issues/1220
https://github.com/angular/angularfire2/issues/1220
With ionoc 3 framework, some of mine dependencies are like these in the package.json file:使用 ionoc 3 框架,我的一些依赖项在 package.json 文件中如下所示:
"angularfire2": "^5.0.0-rc.11",
"firebase": "^5.0.4",
"rxjs": "^6.0.0",
"rxjs-compat": "^6.2.1",
And this works for me:这对我有用:
this.afs.list("marker").valueChanges().subscribe( (data: any) => {
data.forEach(item => {
console.log("Lat: "+item.lat+" Lng: "+item.lng)
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.