AngularJS Tutorial - Radio input directives








The following code shows how to use radio input directives.

Example


<!DOCTYPE html>
<html  ng-app>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
</head><!--  w  w  w  .  jav a2  s.c om-->
<body>
  <h1>User Info</h1>
  <label>Sex</label>
  <label class="radio">
     <input type="radio" 
            ng-model="user.sex" 
            value="male"> Male</label>
  <label class="radio">
     <input type="radio" 
            ng-model="user.sex" 
            value="female"> Female</label>
  
  <pre ng-bind="user | json"></pre>
</body>
</html>

The code above is rendered as follows: