AngularJS dispone di una direttiva specifica per gestire le opzioni selezionate in una select box.
La direttiva ng-selected
imposta l'attributo selected
di un elemento option
in base all'espressione booleana passata:
<!DOCTYCPE html>
<html ng-app="MyApp">
<head>
<script src="angular.js"></script>
</head>
<body>
<label>Select Two:</label>
<input type="checkbox"
ng-model="isTwo"><br/>
<select>
<option>One</option>
<option ng-selected="isTwo">Two</option>
</select>
<script>
angular.module('MyApp', []);
</script>
</body>
</html>