Is there a way to use console.log()
to output the selected radio button? I attempted to set a default selection with checked="checked"
, but it didn't function as expected.
<body ng-app="app">
<div class="container" ng-controller="radioController">
<label for="redRadio">Red:</label>
<input id="redRadio" type="radio" ng-model="colorValue" value="red" /><br />
<label for="greenRadio">Green:</label>
<input checked="checked" id="greenRadio" type="radio" ng-model="colorValue" value="green" /><br />
<label for="blueRadio">Blue:</label>
<input id="blueRadio" type="radio" ng-model="colorValue" value="blue" /><br />
<br />
<strong>Selected color:</strong> {{colorValue}}<br />
</div>
<script>
angular.module("app", [])
.controller("radioController", function ($scope)
{
});
</script>
</body>