I recently created a dynamic form with data from an API, including an ng-repeat to generate multiple radio buttons. Everything is working well, but I'm struggling to set the first radio button as checked by default. Any suggestions or solutions would be greatly appreciated.
<div ng-repeat="carrier in options.shipping.methods">
<fieldset>
<input type="radio" id="{{ carrier.slug }}" name="{{ carrier.slug }}" value="{{ carrier.slug }}" ng-model="data.shipping" />
<label class="radio" for="{{ carrier.slug }}">{{ carrier.description }}</label>
</fieldset>
</div>
Would setting ng-init
to $index == 0
work in this case?