AngularJS – Select value property in ng-options

The angular select ng-options attribute is really useful to dynamically generate the options of a select. Additionally​, it brings another great benefit, the possibility​ of selecting as value other javascript data types and not only strings.

Example of use:

angular.module('demoApp', []).controller('DemoController', function($scope) {

 $scope.options = [
 { label: 'one', value: 1 },
 { label: 'two', value: 2 }
 $scope.numberSelected= $scope.options[1].value;

<body ng-app="demoApp">
  <div ng-controller="DemoController">
    <select ng-model="numberSelected" ng-options="opt.value as opt.label for opt in options">

     The value selected is {{ numberSelected }}.