ngular ionic select ng-options 默认选择第一个值的写法

时间:2022-07-03 08:28:55

1. html

<select ng-model="selectOrderState" style="border:none;left:0" ng-options="state.name for state in orderStates"></select>

2. js

    //订单状态
$scope.orderStates=[
{name:'全部',id:""},
{name:'等待审核',id:"252001"},
{name:'审核通过',id:"252002"},
{name:'审核未通过',id:"252003"},
{name:'用车中',id:"252004"},
{name:'已还车',id:"252005"},
{name:'已取消',id:"252006"},
{name:'过时未审',id:"252007"}
];
//设置默认选择选项
$scope.selectOrderState=$scope.orderStates[0]

3. 获取选择值

$scope.selectOrderState.id