You either need to specify a different name for each switch, or you need to flip each switch in an ng form (each of which has a different name). If you use two inputs with the same name in the same form, only the latter will be bound to the FormController property. If you use different names, each input will have its own property on the FormController.
An example with different names for each switch: http://jsfiddle.net/BEU3V/
<form name="form" novalidate> <input type="radio" name="myRadio1" ng-model="myRadio" ng-click="" value="Rejected" required>Rejected<br /> <input type="radio" name="myRadio2" ng-model="myRadio" ng-click="" value="Approved" required>Approved<br /> Form $dirty: {{form.$dirty}}<br /> Field1 $dirty: {{form.myRadio1.$dirty}}<br /> Field1 $dirty: {{form.myRadio2.$dirty}}<br /> Value: {{myRadio}} </form>
An example of wrapping using an ng form: http://jsfiddle.net/39Rrm/1/
<form name="form" novalidate> <ng-form name="form1"> <input type="radio" name="myRadio" ng-model="myRadio" ng-click="" value="Rejected" required>Rejected<br /> </ng-form> <ng-form name="form2"> <input type="radio" name="myRadio" ng-model="myRadio" ng-click="" value="Approved" required>Approved<br /> </ng-form> Form $dirty: {{form.$dirty}}<br /> Field1 $dirty: {{form.form1.myRadio.$dirty}}<br /> Field2 $dirty: {{form.form2.myRadio.$dirty}}<br /> Value: {{myRadio}} </form>
If you need one check for a radio group, you can wrap all the radio buttons in your own ng form and call it something like name = "radioGroup".
http://jsfiddle.net/6VVBL/
<form name="form" novalidate> <ng-form name="radioGroup"> <input type="radio" name="myRadio1" ng-model="myRadio" ng-click="" value="Rejected" required>Rejected<br /> <input type="radio" name="myRadio2" ng-model="myRadio" ng-click="" value="Approved" required>Approved<br /> </ng-form> Form $dirty: {{form.$dirty}}<br /> Group $valid: {{form.radioGroup.$valid}}<br /> Group $dirty: {{form.radioGroup.$dirty}}<br /> Value: {{myRadio}} </form>
Craig Squire Mar 04 '14 at 20:02 2014-03-04 20:02
source share