0

How to access an item in the array using a parent index?

I want to something like this: this.[../index].[1]

But no output is displayed. I tried displaying via {{../index}} and it works. How come when I put it inside the [] to use, it's not working. Does anyone have an idea?

Data:

{ values: [[1,1],[2,2]], options: { english: [[1,'one'],[2,'two']], spanish: [[1,'uno],[2,'dos']]} }

Code: {{#each values}} {{#each options}} this.[../index].[1] {{/each}} {{/each}}

The intended display is this:

1 1 one uno

2 2 two dos

cancelledout
  • 538
  • 1
  • 10
  • 24
  • Found a solution in http://stackoverflow.com/questions/8044219/handlebars-access-array-item/13704081#13704081 : Handlebars.registerHelper('index_of', function(context,ndx) { return context[ndx]; }); But I'm leaving this question open since I still want to know why it isn't possible. – cancelledout Jan 14 '15 at 04:59
  • is not `{{@index}}` working? – andrusieczko Jan 16 '15 at 08:30

0 Answers0