Mel
Mel

Reputation: 245

AngularJS radio button issue

I have the following in a jade file

....
input(id='prefChangeY', type='radio', ng-value='Yes', ng-model='form.prefChange', name='prefChange', on-focus="fieldInfo='Select yes to change your pref'")
.....
input(id='prefChangeN', type='radio', ng-value='No', ng-model='form.prefChange', name='prefChange', on-focus="fieldInfo='Select no to change your pref'")
.....

In the controller I have the following code

$scope.form.prefChange = 'No';

Unfortunately, I am unable to get the No radio button to be selected by default.

Any assistance will be much appreciated.

Melroy

Upvotes: 0

Views: 1288

Answers (2)

zs2020
zs2020

Reputation: 54543

Use value instead of ng-value. Check the doc.

value='Yes'
value='No'

Demo: http://jsfiddle.net/LNWNz/

Upvotes: 2

Juliane Holzt
Juliane Holzt

Reputation: 2145

The attribute for the value when selected is not ng-value but simply value.

See http://docs.angularjs.org/api/ng.directive:input.radio

<input type="radio"
   ng-model="{string}"
   value="{string}"
   [name="{string}"]
   [ng-change="{string}"]>

Upvotes: 1

Related Questions