简体   繁体   English

AngularFire 5:list().valueChanges() 不返回任何要订阅的内容

[英]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.

相关问题 从angularfire数据库列表中返回的值订阅 - return value from angularfire database list subscribe subscribe 方法是否在完成后返回一个列表? - Does the subscribe method return a list after completion? Angularfire2 / Firebase - 在运行时无法使用angularfire2列表进行查询 - Angularfire2/Firebase - query with angularfire2 list subscribe on runtime not working 如何在angular 7 FormGroup valueChanges中删除多个订阅列表中的特定订阅? - how to remove specific subscribe in multiple subscribes list in angular 7 FormGroup valueChanges? valueChanges()仅返回列表更改的受影响项 - valueChanges() to only return affected items of a list change Angular2:在formbuilder中订阅值更改 - Angular2: Subscribe valuechanges in formbuilder 订阅输入值更改并请求发现 - Subscribe to input valuechanges and request to spotify 在Angular2中对valueChanges进行空订阅 - Empty subscribe on valueChanges in Angular2 Angularfire错误:类型&#39;Promise&#39;中不存在“属性&#39;subscribe&#39; <any> &#39;。” - Angularfire error: “Property 'subscribe' does not exist on type 'Promise<any>'.” forkJoin 不适用于 AngularFire2 valueChanges - forkJoin doesn't work with AngularFire2 valueChanges
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM