1.HTML代码
<body ng-app="MyModule">
<div ng-controller="MyCtrl">
<select ng-model="mylabel"ng-options="v.label for v in lists"></select>
</div>
</body>
2.JS代码
var myModule =angular.module("MyModule", []);
myModule.controller('MyCtrl', ['$scope',
function($scope) {
$scope.lists= [
{"label": "步伐1","value" :"111"},
{"label": "步伐2","value" :"233"}
];
$scope.mylabel= $scope.lists[0];//默认数组第一个作为option的值
}
]);
4.延伸–ng-options用法[1]
ng-optins属性可以在表达式中使用数组或对象来自动生成一个select的option列表,与ng-repeat类似。
一般用法:
对于数组:
l v.value for v in array
l v.value as v.label for v in array //将v.label值作为v.value
对于对象:
l label for (key , value) in object
l select as label for (key ,value) in object
5.引用:更多用法参考链接