简单的问题,我希望...
如何在页面加载时使用下面的 html 检查第一个 radio ?
<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>
我尝试使用checked作为attr,但这会被忽略。我还尝试过使用 ng-checked 指令将 resource.type 设置为“pdf”。
最佳答案
这应该有效
<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/
关于javascript - Angular - 如何强制在页面加载时检查 radio ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39664221/