I have defined an array of objects in my schema and now want to show objects properties into my template but not getting how to do it.
ingredients: {
type: [Object],
minCount: 1
},
"ingredients.$.name": {
type: String
},
"ingredients.$.amount": {
type: String
}
and trying to access them inside template
<li class="list-group-item">{{ingredients.$.name}} - {{ingredients.$.amount}}</li>
so can you please help me how to access them inside template.
Assuming that I understand correctly and that you have a collection with data in that schema, then you just need to get that data (eg, with a helper called ingredients
) and then use #each
in your template:
{{#each ingredients}}
<li class="list-group-item">{{name}} - {{amount}}</li>
{{/each}}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.