简体   繁体   中英

Angular JS Values selected in drop down not shown

我在 Angular JS 中使用带有 ng 选项的选择。我正在通过 ng-model 对象设置默认值(选择一个选项作为第一项)。当我点击下拉菜单时,我可以看到它在下拉,但没有显示这些值(选择一个选项)。你们中的任何人都可以帮我吗

 var app = angular.module('myApp', []); app.controller('myCtrl', function($scope) { $scope.form = {}; $scope.form.options = [1, 2, 3, 4, 5]; });
 <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> <!DOCTYPE html> <html ng-app='myApp'> <head> <meta charset="UTF-8"> <title>Test</title> </head> <body ng-controller="myCtrl"> <div ng-show="form.selected"> Selected Option: {{form.selected}} </div> <select name="select" ng-model="form.selected"> <option value="">---Please select---</option> <option ng-repeat="opt in form.options" value="{{opt}}" ng-bind="opt"></option> </select> </body> </html>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM