1、问题背景
一般情况下,select下都会有option,但是AngularJS中有指令ng-options,就可以实现select下拉框
2、实现源码
<!DOCTYPE html> <html> <head> <Meta charset="UTF-8"> <title>AngularJS之下拉框(方式一)</title> <script type="text/javascript" src="../js/angular.min.js" ></script> <script> var app = angular.module("selApp",[]); app.controller("selCon",function($scope){ $scope.options = ["第一季度","第二季度","第三季度","第四季度"]; }); </script> </head> <body> <div ng-app="selApp" ng-controller="selCon"> <select ng-model="selectedName" ng-options="x for x in options" style="width: 180px;"> </select> </div> </body> </html>
3、问题说明
<select>
<option></option>
</select>
利用指令ng-options,可以省略<option></option>
原文链接:https://www.f2er.com/angularjs/149022.html