0

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.

1 Answer 1

2

You can use get helper.

{{#each array1 as |element index|}}
   <Component1 @prop={{element}} @prop2={{get @array2 index}} />
{{/each}}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.