I have a variable defined as HashMap
in rs file:
sampleDir: HashMap<String, String>
and is initialized as the following (for example), it's two dimensional:
First | Second |
---|---|
aa | ba |
ab | bb |
ac | bc |
sampleDir: HashMap::from([((&"aa").to_string(), (&"ab").to_string()),
((&"ba").to_string(), (&"bb").to_string()),
((&"ca").to_string(), (&"cb").to_string())].iter().cloned().collect())
I'm trying to access to those two elements in sampleDir
in hbs file (for example):
{{#each sampleDir as |s|}}
<tr>
<th>
how can I access to the first element? i.e. aa, ba, ca
</th>
<td style="width: 100%;">
how can I access to the second element? i.e. ab, bb, cb
</td>
</tr>
{{/each}}
I use this
like the following, but it only access to the second element, i.e. ab, bb, cb:
{{#each sampleDir as |s|}}
<tr>
<th>
{{this}}
</th>
<td style="width: 100%;">
{{this}}
</td>
</tr>
{{/each}}
Any help would be greatly appreciated!
After some investigation, here is the solution:
{{#each sampleDir as |s|}}
<tr>
<th>
{{@key}}
</th>
<td style="width: 100%;">
{{this}}
</td>
</tr>
{{/each}}