如何直接在Ionic 2中获取添加的Firebase项目的ID /密钥?
问题描述:
我试图增加处理如何直接在Ionic 2中获取添加的Firebase项目的ID /密钥?
例如后得到添加项目的ID /关键,这是我的附加功能
add(){
let todayTime = moment().format('YYYY-MM-DD, HH:mm')
this.afd.list('/questions/').push({
uemail: this.userService.email,
title: this.variables.title,
text: this.variables.text,
type: this.variables.type
})
}
所以,我怎么能直接(获得ID,当项目成功添加)?
答
据火力doc
let key = this.afd.list('/questions/').push().key;
你得到推你的数据之前的关键。当你需要同时使用不同位置添加数据时,它非常有用.update()
谢谢..其作品 –