Hi everyone,
I was wondering if there's a way to convert a string into a variable name. For example, I want to convert "minXLabel"
to minXLabel
so that I can use it within span
tags like this:
<span>{{minXLabel}</span>
.
I currently have
<div class="placeholder-value">
<span>{{ inputsArray[index].firstOption || placeholder[index].first}} - </span>
<span>{{ inputsArray[index].secondOption || placeholder[index].second}}</span>
</div>
and the input array looks like this:
inputsArray : [
{ 'firstOption': "minXLabel", 'secondOption': "maxXLabel" },
{ 'firstOption': "minXLabel", 'secondOption': "minYLabel" },
{ 'firstOption': "maxYLabel", 'secondOption': "maxXLabel" },
{ 'firstOption': "maxYLabel", 'secondOption': "minYLabel" }
],
I could do it manually with
<span>{{ minXLabel || placeholder[index].first}} - </span>
, but since I want to iterate over different keys in a loop, I need to find a way to dynamically convert strings into variable names.