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'}
    ]
})

angularJS select

相关文章:

  • 2022-02-08
  • 2021-08-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-24
  • 2021-10-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案