0

I am using the following piece of code for selecting the first option for radio button, but somehow it doesn't seem to work

<label class="radio inline">
    <input type="radio" ng-value="true" name="smsEnabled" ng-model="contactNumberArray.smsEnabled1" ng-checked="true">Yes
</label>
<label class="radio inline">
    <input type="radio" ng-value="false" name="smsEnabled" ng-model="contactNumberArray.smsEnabled1">No
</label>

Can someone suggest some work around for this ?

1 Answer 1

1

Hi in your controller you have to set default value for contactNumberArray please see here: http://jsbin.com/dafoj/1/edit

JS:

  $scope.contactNumberArray ={

    smsEnabled1 : true
  };

HTML:

 <label class="radio inline">
    <input type="radio" ng-value="true" name="smsEnabled" ng-model="contactNumberArray.smsEnabled1" ng-checked="true">Yes
</label>
<label class="radio inline">
    <input type="radio" ng-value="false" name="smsEnabled" ng-model="contactNumberArray.smsEnabled1">No
</label>
Sign up to request clarification or add additional context in comments.

2 Comments

i found the solution and also instead of ng-value, value attribute has to be used!!
there is always more to one solution of any problems

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.