![](/img/trans.png)
[英]Using Passed Mongodb retrieved data by express through res.render('jadeview', mail:mongodbretriveddata) in script. tag in Jade view?
[英]Why if/else for retrieved mongodb data is not working in Jade view
在我的Jade視圖中,我有“原始”,其中包含檢索到的mongodb數據,這些數據已由res.render('jadeview',{raw:mongodbdata})傳遞到我的Jade視圖中。
body
.container
h1 View Requests Page
table
tbody
tr
th ID
th Request's
th Description
th Current Status
- if(raw.length)
each item in raw
tr
td
a(href='/individualrequest/#{item._id}', id="idanch") #{item._id}
td
a(href='/individualrequest/#{item._id}', id="rqstanch") #{item.request}
td
a(href='/individualrequest/#{item._id}', id="descanch") #{item.description}
td
-if( #{item.approval} === 'true')
p Approved
else
p Rejected
但是對於最后的td,我正在將檢索到的“ raw”值與if else語句之一進行比較,我得到的錯誤是“ 500 Unexpected character'#'”,我嘗試使用#{item.approval}來代替,我比較了'true'==='true',然后工作正常,我在Jade View頁面中得到了輸出,但是如果我只給出td#{item,為什么它不使用#{item.approval} .approval},我正在獲取價值,但如果沒有,則不可以,請幫助我
- if(item.approval)
應該可以正常工作,無需將其轉換為字符串,然后與另一個字符串進行比較
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.