【问题标题】:AngularFire2 v5 not binding the $key propertyAngularFire2 v5 未绑定 $key 属性
【发布时间】:2018-04-05 21:02:36
【问题描述】:

我正在检索使用 angular fire 的用户列表,如下所示:

this.db.list<IUser>("usersinteam/04f27419-f466-4c5e-9816-fbf120713c4e").valueChanges<IUser>().subscribe( res => console.log (res), error => console.log (error), () => console.log ("complete") );

typescript 中的 IUser 界面如下所示:

export interface IUser{ $key: string, name: string, moto: string }

firebase json 结构如下所示: { "04f27419-f466-4c5e-9816-fbf120713c4e" : { "2b395659-26f4-4c5c-a1b2-fd492d51ff5d" : { "moto" : "Nah!", "name" : "Maria" }, "6b5c19b0-f176-4af1-ab19-ae7ec4c06a5a" : { "moto" : "Yeah!", "name" : "David" }, "ee067245-f085-4c33-acaa-a16deb945cee" : { "moto" : "wrecking ball", "name" : "Ian" } } } 我得到一个 IUser 对象列表,其中 name 和 moto 属性正确填充。但是 $key 属性是未定义的。我期待看到 $key 属性设置为每个用户的键。我怎样才能做到这一点?

【问题讨论】:

    标签: typescript firebase angularfire


    【解决方案1】:

    他们在版本 5 中取消了 $key 方法。这里有更多详细信息

    https://github.com/angular/angularfire2/blob/master/docs/version-5-upgrade.md

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-02-26
      • 1970-01-01
      • 1970-01-01
      • 2012-07-18
      • 2015-01-22
      • 2012-03-08
      • 2022-06-10
      相关资源
      最近更新 更多