gpt4 book ai didi

javascript - angular js ng-repeat范围内的单选按钮列表,默认选中

转载 作者:行者123 更新时间:2023-11-29 10:14:34 25 4
gpt4 key购买 nike

app.controller('radiusController', function($scope){
$scope.radii = [
{id:.25, checked:"false", name:"1/4 Mile"},
{id:.5, checked:"false", name:"1/2 Mile"},
{id:1, checked:"false", name:"1 Mile"},
{id:2, checked:"true", name:"2 Mile"},
{id:3, checked:"false", name:"3 Mile"},
{id:4, checked:"false", name:"4 Mile"},
{id:5, checked:"false", name:"5 Mile"}
];
$scope.handleRadioClick = function(radius){
window.radiochecked = radius.id;
};
});

<li ng-repeat="radius in radii" id="selectradius-{{radius.id}}">

<div class="radio">
<label>

<input type="radio" name="radius"
ng-model="radius.checked"
ng-change="handleRadioClick(radius)">

{{radius.name}}

</label>
</div>

</li>

如何根据范围半径的选中值设置要选中的默认单选按钮?在这种情况下,应默认选中“2 英里”。

笨蛋:http://plnkr.co/edit/RP9SpO1qGjn5Ua6pZJ3D?p=preview

最佳答案

简单。尽管 Angular 文档没有提到 ng-checked,但它是可用的。

<input type="radio" name="radius"
ng-change="handleRadioClick(radius)"
ng-checked="radius.checked">

关于javascript - angular js ng-repeat范围内的单选按钮列表,默认选中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25389701/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com