How to add checked class to a radio button in AngularJS
angularjs
Solution
You need to give the radio input a value.
For more examples see http://docs.angularjs.org/api/ng/input/input%5Bradio%5D.
<div ng-app>
<label ng-class="{checked: isChecked == 1}">
<input type="radio" name="menuType" ng-model="isChecked" value="1" />Text 1
</label>
<label ng-class="{checked: isChecked == 2}">
<input type="radio" name="menuType" ng-model="isChecked" value= "2" />Text
</label>
</div>
Problem
In AngularJS, I'm trying to add/remove a `checked` class on a parent element, when its child radio button is checked/unchecked. ``` <label ng-class="{checked: menuType.isChecked0}"> <input type="radio" name="menuType" ng-model="menuType.isChecked0" />Text 1 </label> <label ng-class="{checked: menuType.isChecked1}"> <input type="radio" name="menuType" ng-model="menuType.isChecked1" />Text 2 </label> ``` Here is a fiddle: http://jsfiddle.net/fAA2w/ There is no controller or any other relative code. If there is a better way to approach this, please share. This seems simple enough, but I cannot find an answer to this question. What am I doing wrong here?