Conditionally add attribute in select option with Aurelia
<p>I am simply trying to create a repeat.for loop which will generate the options for a select element in a form in my application. I wish to add the <code>selected</code>
attribute to the last option of my select element but cannot figure out how to manage it. The code for my select looks as follows:</p>

<pre><code>&lt;select select class="browser-default" value.bind="maxPlayers"&gt;
  &lt;option repeat.for="num of numPlayers" value.bind="num"&gt;${num}&lt;/option&gt;
&lt;/select&gt;
</code></pre>

<p>and the numPlayers property of my view-model class is just a simple array:</p>

<pre><code>numPlayers = [2, 3, 4];
</code></pre>

<p>So my question is how can I add the selected attribute to only the last option element in my select element? I know that there is a boolean value named $last that indicates whether or not I am on the last element, but I cannot figure out how to properly incorporate that. It seems that I should be able to get it work by adding <code>selected.bind="$last"</code> to the option element, but that does not seem to have any effect. </p>