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>
How do I set the default radio button to be checked based on the checked value of scope radii? In this case the "2 Mile" should be checked by default.
plunker: http://plnkr.co/edit/RP9SpO1qGjn5Ua6pZJ3D?p=preview
$scope.radius.checked = $scope.radii[0]