html代码为,如果ng-model的值在InPageSel里有的话,界面上是选中的。但是如果没有,界面上选择的是空白栏,界面下拉内容有很多,希望能做到默认选中第一个。
<select ng-model="auth_policy.p_info.high_action.action_annex.page" ng-options="en as en for en in InPageSel" style="width:150px;"></select>
js代码,select数据是从后台get过来然后放在InPageSel数组里的
$scope.InPageSel = [];
angular.forEach(data_select.script_pagelist,function(v,k){
this.push(v.page_name);
},$scope.InPageSel);
There are many methods. I personally think the most stable method is:
<select ng-model="selected" ng-options="x.id as x.name for x in users"></select>
You can consider giving auth_policy.p_info.high_action.action_annex.page a value contained in the content after get