访问由 meteor autoform 创建的数组和对象

Access array and object created by meteor autoform

我正在尝试访问 meteor auto-form 创建的数组中的信息。有问题的集合如下。

 PlayersSchema = new SimpleSchema({

   contacts: {
    type: Array,
    optional: true
  },

    "contacts.$": {
    type: Object
  },


  "contacts.$.comments": {
    type: String,
    label: "Comments From Salesmen"
  }

});

我需要在最后一个区块的评论中完成,但我没有任何运气。 当您访问第一部分时,它会联系它 returns object Object,这是可以预料的。但是当我尝试更深入地访问评论部分时,我没有运气。我试过 contacts.comments - 和 contacts.comments[0] 都没有反应。

这是我的控制台的屏幕截图,显示了我需要到达的评论的位置

Console Array Comment Placement

收到评论后,我想将它们放在下面的模板中。就像我说的,我可以让 object Object 以这种形式显示,但没有别的。

<template name="showPerson">
  {{#with person}}
  <h1>Show Person Details: {{name}}</h1>
  <div class="row">

      Comments: {{contacts.comments}}

  </div>
  {{/with}}
  {{> update}}
</template>

刚接触javascript和meteor所以请原谅我的无知!!

您还可以循环浏览联系人:

{{#each contacts}}
    {{comments}} <!-- this might also need a loop -->
{{/each}}

如果 Contacts 是一个不同的集合,请确保您有 return 游标的助手以便循环