AngularJS enables you to generate dropdown lists from items in an array or an object.
To create a dropdown list based on an object or an array in AngularJS, you should utilize the ng-options directive.
<div ng-app=”myApp” ng-controller=”myCtrl”>
<select ng-model=”selectedName” ng-options=”x for x in names”> </div> <script> var app = angular.module(‘myApp’, []);
app.controller(‘myCtrl’, function($scope) { $scope.names = [“Emil”, “Tobias”, “Linus”]; }); </script>
|