How to use ng-options to create a dropdown menu with options from an array in angularJS

<div ng-app="optionsApp" ng-controller="OptionsController">
    <select ng-model="selectedOption" ng-options="item for item in options">
        <option value="">-- Select an option --</option>
    </select>
    <p>You selected: {{ selectedOption }}</p>
</div>

<script>
    var app = angular.module('optionsApp', []);
    app.controller('OptionsController', function($scope) {
        $scope.options = ['Option 1', 'Option 2', 'Option 3'];
    });
</script>

 

Post your Answer