I am trying to return a value of an objects that are inside of an array.
(我试图返回数组内部对象的值。)
const bugSchema = new Schema({ title: { type: String, required: true }, comments:[ { user:{ type: String, required: true }, content: { type: String, required: true } } ] });
I have tried the following function but it does not return anything.
(我尝试了以下功能,但未返回任何内容。)
<% for (bug of bugs) { %> <ion-card> <ion-card-header> <ion-card-title><%= bug.comments.filter(function (value) { value.content }) %></ion-card-title> </ion-card-header> <ion-card-content> </ion-card-content> </ion-card> <% } %>
However I can return an array but it returns the entire objects rather than value of each one.
(但是我可以返回一个数组,但它返回整个对象,而不是每个对象的值。)
<% for (bug of bugs) { %> <ion-card> <ion-card-header> <ion-card-title><%= bug.comments %></ion-card-title> </ion-card-header> <ion-card-content> </ion-card-content> </ion-card> <% } %>
The screenshot below shows how the object looks like
(下面的屏幕截图显示了对象的外观)
What I am expecting to achieve is to create a ion-card populated with comment's content.
(我期望实现的目标是创建一个包含评论内容的离子卡 。)
ask by HalfMartianHalfHuman translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…