我已经在架构中定义了一个对象数组,现在想要将对象属性显示到我的模板中,但不知道如何执行此操作。
ingredients: {
type: [Object],
minCount: 1
},
"ingredients.$.name": {
type: String
},
"ingredients.$.amount": {
type: String
}
并尝试在模板内访问它们
<li class="list-group-item">{{ingredients.$.name}} - {{ingredients.$.amount}}</li>
那么您能帮我如何在模板中访问它们吗?
最佳答案
假设我理解正确并且您有一个包含该架构中的数据的集合,那么您只需要获取该数据(例如,使用名为 ingredients
的帮助程序),然后使用 模板中的#each
:
{{#each ingredients}}
<li class="list-group-item">{{name}} - {{amount}}</li>
{{/each}}
关于javascript - AutoForm-访问模板内对象属性数组的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33402978/