<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 **.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With