0
<input type="checkbox" ng-model="master" ng-checked="false" name="one"><br/>
<input type="checkbox" ng-disabled="master" name="two">  

It works. But if i replace "checkbox" to "radio" it doesn't work. I tired to try make one radio disabled when other checked.

Why it doesn't work? How to do this?

thanks.

2 Answers 2

2

Radio button use ng-value instead... Radio button work based on value to mark a value as selected. You need either [value="" | ng-value=""]

<input type="radio"
       ng-model=""
       [value="" |
       ng-value=""]>

Like:

 <input type="radio" ng-value="true" name="boolean" ng-model="myValue" /> True
 <input type="radio" ng-value="false" name="boolean"  ng-model="myValue" /> False 

Here is a Online Demo

Or with strings values like:

$scope.myValue = 'Car'

html

 <input type="radio" ng-value="'Car'" name="string1" ng-model="myValue" /> Car
 <input type="radio" ng-value="'Airplane'" name="string1"  ng-model="myValue" /> Airplane 

Here is the second Online Demo

Sign up to request clarification or add additional context in comments.

1 Comment

the question was: How to make one radio disabled when other checked. And notice - that radios were in separate groups. But I'll try. Sorry, i'm a very beginner.
0

For me this works fine.

HTML

<input class="radio2" type="radio" id="r1" name="group1"
       ng-model="radioValue"
       ng-value="1">
<input class="radio2" type="radio" id="r2" name="group1"
       ng-model="radioValue"
       ng-value="2">

Inside Your Controller

$scope.radioValue = -1; /* Select none. */
$scope.radioValue = 0; /* Select none. */
$scope.radioValue = 3; /* Select none. */
$scope.radioValue = 1; /* Select r1. */
$scope.radioValue = 2; /* Select r2. */

var selected = $scope.radioValue; /* get selected value. */

2 Comments

if i add ng-checked="false" to the input, $scope.radioValue is 2.
In r1 input you added this?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.