Ember/ Liquid - 各语句多维数组
Ember/ Liquid - Each statement multi-dimentional array
我在使用 ember #each 语句时遇到了一些困难。我想在下面的 HTML 代码中打印多维数组的第 [0] 和 [1] 位置值。即,我想在单独的 HTML 代码块中打印值 Product 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>
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>
我在使用 ember #each 语句时遇到了一些困难。我想在下面的 HTML 代码中打印多维数组的第 [0] 和 [1] 位置值。即,我想在单独的 HTML 代码块中打印值 Product 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>
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>