Reputation: 194
Trying to use the index value in a loop in EmberJs
Consider the following scenario,
{{#each array1 as |element index|}}
<Component1 @prop={{element}} @prop2={{@array2[index]}} />
{{/each}}
I wish to send the object from the second array using the index value from first array. I cannot find any references to this. Any References i found use the first array alone and and didn't use the index in another variable. Thanks in advance for your time and effort.
Upvotes: 0
Views: 200
Reputation: 819
You can use get helper.
{{#each array1 as |element index|}}
<Component1 @prop={{element}} @prop2={{get @array2 index}} />
{{/each}}
Upvotes: 2