您的位置:首页 > Web前端 > AngularJS

angularJS select

2016-04-01 13:07 567 查看
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'}
]
})


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: