Javascript-angular js ng-repeat单选按钮列表从范围,默认选中
作者:互联网
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
解决方法:
简单.即使有角度的文档没有提到ng-checked,它仍然可用.
<input type="radio" name="radius"
ng-change="handleRadioClick(radius)"
ng-checked="radius.checked">
标签:angularjs,ng-repeat,javascript,jquery 来源: https://codeday.me/bug/20191029/1958409.html