AngularJS Tutorial - Bind boolean scope value to select element








The following code shows how to bind boolean scope value to select element.

Example


<!DOCTYPE html>
<html  ng-app>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
<script type='text/javascript'>
function MyCntrl($scope) {<!-- ww  w.j a va  2  s  .co m-->
  $scope.mybool = true;
}
</script>
</head>
<body>
  <div ng-app="">
  <div ng-controller="MyCntrl">
    <select ng-model="mybool">
        <option value="false">Not Included</option>
        <option value="true">Included</option>
    </select>
    <p>
    Currently selected: {{ mybool }}
   </p>
 </div>
</div>
</body>
</html>

The code above is rendered as follows: