首页 > 解决方案 > 使用 Ionic 3 从 Firebase 中删除数据

问题描述

我想从 firebase 中删除数据,但我发现的所有文档都说使用 .remove() 函数,因为我在这里显示为代码片段。但这不适用于 Ionic 3。该功能是否已更改或者我没有看到的重点是什么。

selectBook(indexOfBook : Book){

    this.actionSheetCtrl.create({
        title: indexOfBook.nameOfBook,
        buttons:[{
               text:'Edit',
               handler: () =>{
                   // TODO:Send the user to EditPage
               }

        },
        {
             text:'Delete',
             role: 'destructive',
             handler: () => {
                 this.getBookRef$.remove(indexOfBook.key);//**************************************
             }
        },
        {
            text:'Cancel',
            role:'cancel',
            handler: () =>{
                   console.log("The user has selected the cancel button");
            }
        }


        ]


    }).present();

}

标签: javascriptangularfirebaseionic-frameworkfirebase-realtime-database

解决方案


推荐阅读