【发布时间】:2023-03-09 09:00:01
【问题描述】:
我有一组日期、月份和年份的单选按钮。
<label>
<input type="radio" ng-model="IsDays" name="timeunit" > Period in days
<input type="radio" ng-model="IsMonths" ng-checked="true" name="timeunit"> Period in months
<input type="radio" ng-model="IsYears" name="timeunit" > Period in years
</label>
我已经读到尽管将选中的属性设置为中间选项,组中的最后一个按钮将被选中,如果单选按钮具有相同的名称属性值。
我在 checked 和 ng-checked="true" 两种情况下都试过这个。
是否有一种简单的方法可以覆盖此行为并允许默认检查中间选项(month)?
更新:解决了我自己的问题。请参阅下面的答案。
【问题讨论】: