标签:
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" ng-app="app"> <head> <title>select</title> <script src="JS/angular.min.js"></script> <script> var app = angular.module(‘app‘, []); app.controller(‘selectController‘, function ($scope) { $scope.mycity = ‘北京‘; $scope.Cities = [{ id: 1, name: ‘北京‘ }, { id: 2, name: ‘上海‘ }, { id: 3, name: ‘广州‘ }]; }); </script> </head> <body> <div ng-controller="selectController"> <select ng-model="mycity" ng-options="city for city in Cities"></select> </div> </body> </html>
直接点出属性即可。
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" ng-app="app"> <head> <title>select</title> <script src="JS/angular.min.js"></script> <script> var app = angular.module(‘app‘, []); app.controller(‘selectController‘, function ($scope) { $scope.mycity = ‘北京‘; $scope.Cities = [{ id: 1, name: ‘北京‘, group: ‘中国‘ }, { id: 2, name: ‘上海‘, group: ‘中国‘ }, { id: 3, name: ‘广州‘,group:‘中国‘ }]; }); </script> </head> <body> <div ng-controller="selectController"> <select ng-model="mycity" ng-options="city.name as city.name group by city.group for city in Cities"></select> </div> </body>
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" ng-app="app"> <head> <title>select</title> <script src="JS/angular.min.js"></script> <script> var app = angular.module(‘app‘, []); app.controller(‘selectController‘, function ($scope) { $scope.mycity = ‘北京‘; $scope.Cities = [{ id: 1, name: ‘北京‘, group: ‘中国‘ }, { id: 2, name: ‘上海‘, group: ‘中国‘ }, { id: 3, name: ‘广州‘, group: ‘中国‘ }]; }); </script> </head> <body> <div ng-controller="selectController"> <select ng-model="mycity" ng-options="city.name as city.name group by city.group for city in Cities"></select> <h1>欢迎来到{{mycity}}</h1> </div> </body> </html>
自己项目代码:
<td> 工资:</br> <select ng-model="GongZiID" ng-options="GongZiList.id as GongZiList.name for GongZiList in GongZiObj" style="width: 152px;"> </select> </td>
$scope.GongZiObj = [{ id: 0, name: ‘未填写‘ }, { id: 1, name: ‘面议‘ }, { id: 2, name: ‘1000以下‘ }, { id: 3, name: ‘1000–2000‘ }, { id: 4, name: ‘2000–3000‘ }, { id: 5, name: ‘3000–4000‘ }, { id: 6, name: ‘4000–6000‘ }, { id: 7, name: ‘6000–8000‘ }, { id: 8, name: ‘8000–10000‘ }, { id: 9, name: ‘10000–20000‘ }, { id: 10, name: ‘20000以上‘ }, ];
$scope.GongZiID = contentDs.source.GongZi;
[Angularjs]ng-select和ng-options(转载)
标签:
原文地址:http://www.cnblogs.com/likaixuan/p/4741541.html