Having a simple component context like this:
{
profile: {
name: 'Tim',
region_id: 1
},
regions: [
{ id: 1, name: 'Region A' },
{ id: 2, name: 'Region B' },
{ id: 3, name: 'Region C' }
]
}
And in the component there is a dropdown like this:
<select name="region">
{{#each regions}}
<option value="{{id}}">{{name}}></option>
{{/each}}
</select>
How can I get the component.profile data inside an #each loop? I was trying something this like this, but inside the #each context, I can’t seem to access the component data:
{{#each regions}}
<option value="{{id}}" {{js_if "this.id === profile.region_id"}} SELECTED {{/js_if}}>{{name}}></option>
{{/each}}
Of course I can set the selected item in the pageInit event, but I would like to keep as much as possible simply in the template.