我在使用ember #each语句时遇到了一些困难。我想在下面的HTML代码中打印多维数组中的第[0]和[1]位置值。即,我想在单独的HTML代码块中打印产品X,Y,Z和GROUP A,B,C的值。 this.get(0)无效。
var uiTags = [
['**Product X**','GROUPA', '350'],
['**Product Y**','GROUPB', '150'],
['**Product Z**','GROUPC', '575']
];
HTML代码:
<ul class="list-group list-group-menu">
{% raw %}{{#each uiTags}}{% endraw %}
<!-- Print product name start (This block should print the product name) -->
<li class="list-group-item"><a href="#">
<div class="checkbox checkbox-primary">
<input type="checkbox" checked id="map-filter-{% raw %}{{ @index }}{% endraw %}" value="{% raw %}{{ this }}{% endraw %}"/>
<label for="map-filter-{% raw %}{{ @index }}{% endraw %}">{% raw %}{{ this }}{% endraw %}</label>
</div></a>
</li>
<!-- Print product name end-->
<!-- Print group name start (This block should print the group name) -->
<li class="list-group-item"><a href="#">
<div class="checkbox checkbox-primary">
<input type="checkbox" checked id="map-filter-{% raw %}{{ @index }}{% endraw %}" value="{% raw %}{{ this }}{% endraw %}"/>
<label for="map-filter-{% raw %}{{ @index }}{% endraw %}">{% raw %}{{ this }}{% endraw %}</label>
</div></a>
</li>
<!-- Print group name end-->
{% raw %}{{/each}}{% endraw %}
</ul>
答案 0 :(得分:0)
You can use the get
helper to access a specific index.:
<ul>
{{#each model as |row|}}
<li>
<ul>
<li>{{get row "0"}}</li>
<li>{{get row "1"}}</li>
</ul>
</li>
{{/each}}
</ul>