AngularJS Tutorial - ng-repeat creates option elements








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. ja  v a 2s . 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>

The code above is rendered as follows: