ng-options指令
在angularJS中创建select下拉是使用ng-options创建下拉项
ng-options="val as label for element in array" //设置option的value值为val
ng-options="lable for element in array" //不设置option的value值,默认为element对象
ng-options="(label)group by group for element in array" //不设置option的value值,默认为element对象
<div ng-controller="selectCtrl"> <select ng-model="menu" ng-options="m.id as m.name for m in selectArray"></select> {{menu}} </div>
myApp.controller('selectCtrl',function($scope){
$scope.selectArray=[
{id:'1', name:'apple'},
{id:'2', name:'pear'}
]
})
