在firebase中检索孩子的孩子

时间:2018-10-30 09:28:44

标签: javascript firebase web

我是Firebase的新手,有人可以告诉我,如果子级“ status”下有两个子级,该如何检索值。这是我的代码:

function tampil(){

    ordersRef.on("value", function(snapshot)
    {
        var data = snapshot.val();
        var files ="";
        for(var key in data)
        {
            files += "<tr>"+
                "<td>" + data[key].name + "</td>"+ 
                "<td>" + data[key].order_date + "</td>"+
                "<td>" + data[key].alamat + "</td>"+
                "<td>" + data[key].status + "</td>"+
                '<td>'+'<button class="btn btn-primary edit" data-validasi="'+key+'">Edit</button>'+'</td>' +
                '<td>'+'<button class="btn btn-danger hapus" data-validasi="'+key+'">Hapus</button>'+'</td>' +
            "<tr>";
        }

        tableValidasi.innerHTML = files;
        if (files !="") {   

            var elementEditTabel = document.getElementsByClassName("edit");
            for (var i =0; i<elementEditTabel.length; i++) {
                elementEditTabel[i].addEventListener("click",editaFirebase,false);
            }


            var elementHapusTable = document.getElementsByClassName("hapus");
            for (var i =0; i<elementHapusTable.length; i++) {
                elementHapusTable[i].addEventListener("click",hapusFirebase,false);
            }
        }
    });
}

0 个答案:

没有答案