ng-selected selects an option value

Description

The following code shows how to use ng-selected to select an option value.

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 QuarterController($scope) {<!--from www. j a  va 2s . c o  m-->
    $scope.Quarter = 3;
}
</script>
</head>
<body>
  <div ng-app>
  <div ng-controller="QuarterController">
    <select name="quarter" ng-model="Quarter" ng-selected="Quarter" >
        <option ng-repeat="v in [1,2,3,4]" value="{{v}}">Q{{v}}</option>
    </select>
  </div>
</div>
</body>
</html>

Click to view the demo





















Home »
  AngularJS »
    AngularJS Example »




Controller
Directives
Expression
Filter
Form
Inject
Scope
Server
Style
Template
Utilities