Simple repeat using data in a variable

I am trying to do a simple repeat based on manually entered data from a variable. This should be 'simple' but for some reason I am struggling, can you help?

            <dmx-value id="var_years_list" dmx-bind:value="2010,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024"></dmx-value>

            <div>
              Years
            </div>
            <div class="btn-group btn-group-toggle d-flex flex-wrap" is="dmx-repeat" data-toggle="buttons" dmx-repeat:repeat1="var_years_list">
              {{$index}} for {{var_years_list[0].value}}
            </div>

I want to end up with a list like

0 for 2010
1 for 2011
2 for 2012
3 for 2013

etc

First thing - use the array component instead of a variable.
Second - i see you want to use some button group, but the syntax is wrong.

Here's the correct code, not sure if these flex- attributes you applied to the button group are there by mistake or not, i just left them there:

<dmx-array id="arr1" dmx-bind:items="[2010,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024]"></dmx-array>
  <div>Years</div>
  <div class="btn-group btn-group-toggle d-flex flex-wrap" is="dmx-repeat" dmx-bind:repeat="arr1.items" data-toggle="buttons">
      <button class="btn">{{$index}} for {{$value}}</button>
  </div>
1 Like

Brilliant! It's simple when you know how. I couldn't get my head away from 'variable'. Don't worry about syntax, flex etc, I cut the code down from a much larger sample. I can sort it from here :slight_smile:

1 Like