Firebase 返回值未在 ejs 中呈现
Firebase returned value not rendering in ejs
在我的 ejs 中我有这个代码:
<% for(var bill in ChildData){ %>
<tr>
<td><%= bill.id %></td>
<td><%= bill.Phone %></td>
<td><%= bill.Amount %></td>
<td><%= bill.Purchase_Date %></td>
<td>View Details</td>
</tr>
<% } %>
在我的节点中我有
app.get("/viewbill", function(req,res){
database.once("value", function (snapshot) {
res.render('viewbills', {ChildData: snapshot.val()});
});
})
但是在我获得的页面上
Screenshot of the output I get
即使我尝试得到相同的结果
<td><%- JSON.stringify(bill.id) %></td>
将 ejs 代码更改为此给了我输出
<% Object.keys(ChildData).forEach(function(key) { %>
<tr>
<td><%- ChildData[key].id %></td>
<td><%- ChildData[key].Phone %></td>
<td><%- ChildData[key].Amount %></td>
<td><%- ChildData[key].Purchase_Date %></td>
<td>View Details</td>
</tr>
<% }); %>
在我的 ejs 中我有这个代码:
<% for(var bill in ChildData){ %>
<tr>
<td><%= bill.id %></td>
<td><%= bill.Phone %></td>
<td><%= bill.Amount %></td>
<td><%= bill.Purchase_Date %></td>
<td>View Details</td>
</tr>
<% } %>
在我的节点中我有
app.get("/viewbill", function(req,res){
database.once("value", function (snapshot) {
res.render('viewbills', {ChildData: snapshot.val()});
});
})
但是在我获得的页面上 Screenshot of the output I get
即使我尝试得到相同的结果
<td><%- JSON.stringify(bill.id) %></td>
将 ejs 代码更改为此给了我输出
<% Object.keys(ChildData).forEach(function(key) { %>
<tr>
<td><%- ChildData[key].id %></td>
<td><%- ChildData[key].Phone %></td>
<td><%- ChildData[key].Amount %></td>
<td><%- ChildData[key].Purchase_Date %></td>
<td>View Details</td>
</tr>
<% }); %>