You can have a look at this code
<div ng-app="myapp">
<fieldset ng-controller="FirstCtrl">
<select ng-options="regione.nome as regione.nome for regione in regioni.regionSelector"
ng-model="selectedRegione"></select>
{{ selectedRegione }}
</fieldset>
</div>
Controller
var myapp = angular.module('myapp', []);
myapp.controller('FirstCtrl', function ($scope) {
$scope.selectedRegione = 'Mike';
$scope.regioni = {
'regionSelector':[
{ id: 1, nome: 'John'},
{ id: 2, nome: 'Rocky'},
{ id: 3, nome: 'Mike'},
{ id: 4, nome: 'Ben' }
]
};
});
The <option>
is created dynamically and the value for the dropdown is pre-selected by $scope.selectedRegione = 'Mike';
which reference the nome: 'Mike'
of the $scope.regioni.regionSelector
array.
For simplicity and work around here is the link to JSFIDDLE
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…