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

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

问题描述

我正在尝试执行多媒体广告联盟路径更新使用Firebase和AngularFire2。然而,当我使用这个时,我得到了上面的错误:

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

如何在使用AngularFire2推送某些东西后得到密钥? $ b

解决方案

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

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


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();

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

解决方案

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天全站免登陆