【发布时间】:2017-06-13 02:16:28
【问题描述】:
我正在使用 TypeScript 构建一个 Angular 4 应用程序,我想使用 update() 方法将一些数据添加到 Firebase 数据库中,同时从 userId 属性中动态指定“键”名称:
this.products = this.afdb.list('/products/');
this.products.update(this.productId, {
this.userId : this.myRating
})
这里的问题是不能将this.userId 添加为“键”名称。谁能给我一个提示?
提前致谢。
【问题讨论】:
-
也许:
this.products.update(this.productId, (o={}, o[this.userId] = this.myRating, o))。但是,创建一个接受this参数并返回您的对象的函数会更好。
标签: javascript angular typescript firebase firebase-realtime-database