The ng-option directive is very simple to use, and only two attributes are required:
One is ng-model for obtaining the selected value;
Another is ng-options to determine the element array of drop-down lists.
1. Problem background
Generally speaking, there will be options under select, but if there is the instruction ng-options in AngularJS, you can implement the select drop-down box.
2. Implement source code
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>AngularJS drop-down box (Method 1)</title> <script type="text/javascript" src="../js/angular.min.js" ></script> <script> var app = angular.module("selApp",[]); app.controller("selCon",function($scope){ $scope.options = ["First Quarter","Quarter","Quarter Fourth Quarter"]; }); </script> </head> <body> <div ng-app="selApp" ng-controller="selCon"> <select ng-model="selectedName" ng-options="x for x in options"> </select> </div> </body> </html>3. Problem description
<select><option></option></select>
Using the instruction ng-options, you can omit <option></option>
The above is the AngularJS using the ng-options command to implement the drop-down box. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to everyone in time. Thank you very much for your support to Wulin.com website!