Reputation: 4872
<select id="Test" TestAttr="{{:LocationId}}">
{{for #parent.parent.data.Location}}
<option value="{{:LocationId}}" {{if LocationId= *#parent.parent.data.LocationId*}}selected{{/if}}>{{:#parent.parent.data.LocationId}}</option>
{{/for}}
</select>
How to get the parent array's LocationId inside if statement which is mentioned in between **.
Upvotes: 7
Views: 6541
Reputation: 1320
You can introduce variable which will be visible inside loop (In official documentation: Setting contextual template parameters, accessible in all nested contexts as ~nameOfParameter)
<select id="Test" TestAttr="{{:LocationId}}">
{{for #parent.parent.data.Location ~locationId=LocationId}}
<option value="{{:~locationId}}"...
The above link is to previous documentation, now superceded.
For current documentation, see Accessing parent data.
See also this stackoverflow question
Upvotes: 13