“字符串"类型没有兼容的调用签名 [英] Type 'String' has no compatible call signatures

查看:26
本文介绍了“字符串"类型没有兼容的调用签名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试做一个多使用 Firebase 和 AngularFire2 更新路径.但是,当我使用它时,我收到了上面的错误:

I'm trying to do a multi-path update using Firebase and AngularFire2. However, I'm getting the error above when I use this:

let fb = firebase.database().ref();
let key = fb.child('/path').push().key();

关于在使用 AngularFire2 推送某些内容后如何获取密钥的任何想法?

Any ideas of how I can get the key after pushing something using AngularFire2?

推荐答案

由于 push 方法现在返回一个 Observable,正确获取生成的 $key (使用 AF2) 执行以下操作:

As the push method now returns an Observable, the proper way to get the generated $key (using AF2) is doing the following:

let fb = this.af.database.list('/path');
fb.push('item').then(res => console.log(res.key));

这篇关于“字符串"类型没有兼容的调用签名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆