AngularJS Tutorial - Bind scope value to radio button








The following code shows how to Bind scope value to radio button.

Example


<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
</head><!--from   www.j av a2  s  . c  o m-->
<body ng-app ng-controller="testcontroller">
  <input type="radio" ng-model="lookup" value="1">Employee Lookup</input>
  <input type="radio" ng-model="lookup" value="5">Company Lookup</input>
<script type='text/javascript'>
function testcontroller($scope){
  $scope.lookup = 1;
}
</script>
</body>
</html>

The code above is rendered as follows: