0

Simple question I hope...

How do I enable on page load that the first radio is checked with the html below?

            <div class="app-margin-bottom app-margin-left">
                <input type="radio"
                       value="pdf"
                       ng-model="resource.type"
                       ng-click="enableUrlInput()"
                       name="resourceType"
                       required>
                    <span class="app-margin-right">PDF</span>
                <input type="radio"
                       name="resourceType"
                       ng-model="resource.type"
                       ng-click="enableUrlInput()"
                       value="url"
                       required> URL
            </div>

I have tried using checked as an attr but this gets ignored. I've also played around with setting resource.type to 'pdf' with the directive ng-checked.

Max Lynn
  • 1,738
  • 6
  • 22
  • 35

1 Answers1

1

This should work

<div ng-controller="MyCtrl">
  <div class="app-margin-bottom app-margin-left">
                <input type="radio"
                       value="pdf"
                       ng-checked="true"
                       ng-model="resource.type"
                       ng-click="enableUrlInput()"
                       name="resourceType"
                       required>
                    <span class="app-margin-right">PDF</span>
                <input type="radio"
                       name="resourceType"
                       ng-model="resource.type"
                       ng-click="enableUrlInput()"
                       value="url"
                       required> URL
            </div>
</div>

JSFiddle: http://jsfiddle.net/Lvc0u55v/9955/

Bartosz Gajda
  • 984
  • 6
  • 14