【问题标题】:how can Access array index in spacebars In meteor如何在流星中访问空格键中的数组索引
【发布时间】:2018-10-16 20:50:56
【问题描述】:

我正在从数据库中获取动态内容,我想查看索引值,例如..1,2,3,4,5,6,7 等等。

我正在使用{{ @index }}{{ index }},但它不适合我。

<template name="getDynamic">    
    <table class="table table-bordered table-striped">
      <thead>
        <tr>
          <td>First Name</td>
          <td>last Name</td>
          <td>Email</td>
          <td>password</td>
          <td>Gender</td>
          <td>Trems</td>
          <td>Actions</td>
        </tr>
      </thead>
      <tbody>
         {{#each  listalltests}}  {{> list }} {{/each}}
      </tbody>
    </table>
</template>

  <template name="list">
  <tr>
    <td> {{@index}} </td> // not working
    <td> {{ username }}  </td>
     <td> {{ lastname }}  </td>
    <td> {{ email }}  </td>
    <td> {{ password }}  </td>
    <td> {{ gender }}  </td>
    <td> {{ terms }}  </td>
    <td>[<a href="#" class="delete-todo">Delete</a>] </td>
    <!-- <td>[<a href="#" class="update-todo">Update</a>] </td> -->
  </tr>
</template>

有没有办法在流星中访问空格键中的数组索引?

【问题讨论】:

    标签: arrays meteor meteor-blaze


    【解决方案1】:

    您的list 模板不知道@index,因此您需要将其传递给模板。

    因此你需要这样称呼它

    {{ &gt; list index=@index }}

    当然,您需要更改列表模板中的代码以访问项目数据:

    &lt;td&gt;{{index}}&lt;/td&gt;

    【讨论】:

    • 非常感谢。
    猜你喜欢
    • 2014-03-15
    • 2015-05-04
    • 2017-06-08
    • 2015-08-02
    • 2015-06-11
    • 2016-07-14
    • 1970-01-01
    • 2015-08-14
    相关资源
    最近更新 更多