AngularJS Tutorial - Bind option value to model








The following code shows how to Bind option value to model.

Example


<!DOCTYPE html>
<html  ng-app>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
</head><!--from  w w  w  .  java2s .c o  m-->
<body ng-app="myApp">
  <div ng-controller="MyCtrl">
  <select ng-model='select'>
      <option>....</option>
      <option value='one'>One</option>
      <option value='Two'>Two</option>
    </select>

    <div>You selected: {{select}}</div>
</div>
<script type='text/javascript'>
var myApp = angular.module('myApp',[]);

//myApp.directive('myDirective', function() {});
//myApp.factory('myService', function() {});

function MyCtrl($scope) {
}
</script>
</body>
</html>

The code above is rendered as follows: