[英]How to use HandleBars to output each element of an array inside a JSON object
[英]How can I show object inside array in JSON in handlebars with NodeJs Express
這是JSON:
{
"_id" : ObjectId("59c3edd10e2a6f083e858036"),
"email" : "aa@aa.com",
"username" : "aa",
"password" : "$2a$10$WcUgbqFjsx.0BwkdEyDNP.R84vz1d7faaL8K0ORcIoBOXOAHxCS3.",
"words" : [
{
"Name" : "xyz"
}
],
"title" : [
],
"__v" : NumberInt(0),
"name" : "obbk"
}
這是我的用於在words
內顯示數據的代碼
{{#users}}
{{#words}}
<h3>{{this.Name}}</h3>
{{/words}}
{{/users}}
但這沒有用。
所以我想知道如何解決此問題,如何在words
顯示Name
,在nodejs中使用車把作為模板從MongoDB數據庫中的JSON內的數組獲取數據。
采用:
{{#users}}
{{#words}}
<h3>{{Name}}</h3>
{{/words}}
{{/users}}
請注意,在外環(通過users
)你已經訪問words
性能,而無需使用this
關鍵字,因此跟上這種邏輯內環(通過內部words
)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.