angular select下拉框 ng-options 3种默认选中方法
1、html代码
<div ng-controller="MyController">
1、ng-model选中:
<select ng-model="value">
<option ng-repeat="item in Array">{{item}}</option>
</select>
2、ng-selected选中:
<select>
<option ng-repeat="item in Array" ng-selected="value2 == item">{{item}}</option>
</select>
3、ng-options:选中:
<select ng-model="value3" ng-options="item for item in Array">
</select>
</div>
2、js代码
<script type="text/javascript">
var myApp = angular.module('myApp', []);
myApp.controller('MyController',['$scope', function($scope) {
$scope.value = 'angular';
$scope.value2 = 'vue';
$scope.value3 = 'react';
$scope.Array = ['JavaScript', 'react', 'angular', 'html5', 'vue'];
}]);
</script>
注:ng-options时需要使用ng-model