ng-select directive binds data to an HTML <select> element.
ng-options can take an object array and get its contents for the option select tag.
It comes in one of the following forms:
The following code shows how to ng-select.
<!--from w ww . j a v a 2 s. c om-->
<!doctype html>
<html ng-app="myApp">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.2/angular.js"></script>
</head>
<body>
<div ng-controller="MyController">
<select ng-model="myValue" ng-options="myValue.name for myValue in myValues">
<option value="">Choose a Value</option>
</select>
{{ myValue.name }}
</div>
<script>
angular.module('myApp', [])
.controller('MyController', function($scope) {
$scope.myValues = [
{name: 'A'},
{name: 'B'},
{name: 'C'},
{name: 'D'},
{name: 'E'}
];
});
</script>
</body>
</html>
The code above is rendered as follows: