Mithun raj
Mithun raj

Reputation: 194

Ember: Selecting the object form array using index in #each loop

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

Answers (1)

Godric
Godric

Reputation: 819

You can use get helper.

{{#each array1 as |element index|}}
   <Component1 @prop={{element}} @prop2={{get @array2 index}} />
{{/each}}

Upvotes: 2

Related Questions