2017-09-23 74 views
0

我試圖增加處理如何直接在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,當項目成功添加)?

回答

1

據火力doc

let key = this.afd.list('/questions/').push().key;

你得到推你的數據之前的關鍵。當你需要同時使用不同位置添加數據時,它非常有用.update()

+0

謝謝..其作品 –