我有基本的标记和js如下。我一整天都在搜索,但无法找到获得所选期权值的解决方案。
AngularJS版本: v1.5.0
HTML
<div ng-controller="AppCtrl">
<select class="form-control" ng-model="selectedValue">
<option value="1">Value 1</option>
<option value="2" >Value 2</option>
<option value="3">Value 3</option>
</select>
<button ng-click="getValue()">Try</button>
</div>
JS
var MyApp= angular.module('MyModule', []);
MyApp.controller('AppCtrl', function($scope) {
$scope.getValue = function () {
console.log($scope.selectedValue);
}
});
console.log($ scope.selectedValue)返回undefined