@index,索引在模板中不起作用。我完全不知道。因此,我已移至{{_view.contentIndex}}以获取索引值。
问题1:
如何通过父索引访问second_dict值?
比方说,我有两个词组
first_dict = [{"name":"x"},{"name":"y"},{"name":"z"}]
second_dict = [{"name":"x"},{"name":"y"}]
{{#each first in first_dict}}
{{_view.contentIndex}} # output as 0,1,2
???{{second_dict._view.contentIndex.name}} # how to access second_dict value based on parent index ?
{{/each}}
答案 0 :(得分:1)
使用{{get}}
帮助程序和自定义{{to-string}}
帮助程序:
{{#each first_dict as |first index|}}
Second dict value: {{get (get second_dict (to-string index)) 'name'}}
{{/each}}