I have a weird situation where I need to use a dynamic string as a variable name in a handlebars loop in my Ember application.
I have a table with some coffee drinks. Let's say I have a couple variables in my controller called "customDrinksList", "customDrink1", and "customDrink2".
customDrinksList is an array with strings ["customDrink1", "customDrink2"]
. customDrink1 and customDrink2 are arrays of drink objects that come from my ember-data store.
{{#each customDrink in customDrinksList}}
<tr>
<td>{{customDrink}}</td>
{{#each drink in customDrink}}
...
{{/each}}
</tr>
{{/each}}
When I do this, customDrink
is just the string but in the {{#each drink in customDrink}}
statement I want to use the variable with that string name instead of using the actual string.
When I substitute in the variable name (such as customDrink1) it returns the drinks as I'm looking for, but I need to have the variable names in customDrinksList be looped through.
Not sure if this is possible since I haven't been able to find any solutions or maybe I should be taking another approach. Any suggestions welcome.
This project is using Ember 1.13.x
Aucun commentaire:
Enregistrer un commentaire