简体   繁体   English

带值的单选选项默认检查

[英]radio option with value to be checked by default

I have a radio option list as shown below.我有一个单选选项列表,如下所示。 I want the first option to be selected by default on first render, but it is not giving the desired output:我希望在第一次渲染时默认选择第一个选项,但它没有给出所需的 output:

<label class="radio normalFontWeight">
                <input type="radio" name="Criteria" data-ng-value="EVERYONE_REVIEWED" data-ng-model="stage.completionRule" checked="checked"> 
                option 1
</label>                                              
<label class="radio normalFontWeight">
                    <input type="radio" name="Criteria" data-ng-value="HAS_MIN_REVIEWS" data-ng-model="stage.completionRule"> 
                    option 2
    </label>

i have tried with both checked="checked" && checked but was not successful, as on first render both of the options r unselected我已经尝试了两个checked="checked" && checked但没有成功,因为第一次渲染两个选项r未选中

I have figured out the problem: The ng-model value needs to be initialized with corresponding input value of radio button to be checked by default ie in my case stage.completionRule = "EVERYONE_REVIEWED"我已经解决了问题: ng-model 值需要用相应的单选按钮输入值进行初始化,默认情况下要检查,即在我的情况下stage.completionRule = "EVERYONE_REVIEWED"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM