遇到一个问题,在控制器里设置了stafftype的默认值
.controller('InfoStaffCtrl', function($scope, $rootScope, $state, $log,$ionicLoading, $timeout,Manpower) {
//列表
$scope.search = {p:1,audittype:'',name:'',stafftype:'',companyname:''};
$scope.staffTypes = ["请选择","飞行员","机务","航务","管理","空管","其他"];
$scope.doSearch = function(){
...
//$scope.number = $scope.search.stafftype;
...
}
function loadData(){
...
}
loadData();
})
然后根据选择stafftype的项进行loaddate,再点击搜索依然是默认的选项
添加angular的ng-selected
<label class="item item-input item-select">
<span class="input-label">人员分类</span>
<select ng-model="search.stafftype">
<option value="{{$index}}" ng-repeat="t in staffTypes" ng-selected="number==$index">{{t}}</option>
</select>
</label>
当搜索提交的stafftype值和页面里下拉选项value相等时,选中该值
PS:
更复杂的循环数据应该得搭配上ng-options吧,还没试过