javascript - AutoForm-访问模板内对象属性数组的值

标签 javascript meteor meteor-autoform

我已经在架构中定义了一个对象数组,现在想要将对象属性显示到我的模板中,但不知道如何执行此操作。

   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/

相关文章:

javascript - meteor ,自动表格,预填充输入

javascript - 客户端html Markdown 转换

javascript - Div 不会居中

javascript - 使用 eval 函数访问数组

javascript - 使输入上的禁用属性与 Meteor 助手 react 的最佳方法是什么?

javascript - 如何在 Meteor 中使用查找和回调

javascript - 如何让我的模式从左侧水平滑入?

javascript - 删除不安全后无法添加食谱并出现错误

javascript - 在javascript中调用prototype.call函数

node.js - meteor 自动形成简单模式 : how to customize validation message?