handlebars.js - Accessing a multidimensional array from a parent each's id in Handlebars -


i have data:

pricegroups: [   {     label: 'rate1",     price: 1.00,     numpeople: 1   },   {     label: 'rate 2",     price: 2.00,     numpeople: 2   },   {     label: 'rate 3",     price: 15.00,     numpeople: 4   }, ]; 

and

labels: [   'solo',   'duo',   'trio'   '4 people',   '5 people ]; 

i want able this:

{{#pricegroups}}    {{for (a = 1; <= {{this.numpeople}}; ++a)}}       <th>{{label[a]}}</th>    {{/for}} {{/pricegroups}} 

i have tried , nothing works.

please help. important.

i think can use this:

{{#each pricegroups}}<th>{{label}}</th>{{/each}} 

the {{#each pricegroups}} gets iteration of pricegroups array , each item of array (which object) presented template 1 after can reference {{label}} property in object.

you don't embed javascript directly handlerbars templates you're trying do.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -

jquery - Keeping Kendo Datepicker in min/max range -