ng-repeat creates option elements

Description

The following code shows how to use ng-repeat creates option elements.

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  .  j  a  v  a2 s  .c  o m-->
<body>
  <body ng-app ng-controller="AppCtrl">
<div>Operator is: {{filterCondition.operator}}</div>
<select ng-model="filterCondition.operator">
   <option ng-repeat="operator in operators" value="{{operator.value}}">{{operator.displayName}}</option>
</select>
</body>
<script type='text/javascript'>
function AppCtrl($scope) {
    $scope.filterCondition={
        operator: 'eq'
    }
    $scope.operators = [
        {value: 'eq', displayName: 'equals'},
        {value: 'neq', displayName: 'not equal'}
     ]
}
</script>
</body>
</html>

Click to view the demo





















Home »
  AngularJS »
    AngularJS Example »




Controller
Directives
Expression
Filter
Form
Inject
Scope
Server
Style
Template
Utilities