我想在更改 ng-change 上的下拉菜单时获得值(value)。我的代码如下:-
<select class="form-control" id="cobSRQ2" ng-change="cobchange()" required>
<option>[Select One]</option>
<option value="Primary" selected>Primary</option>
<option value="Secondary">Secondary</option>
<option value="Tertiary">Tertiary</option>
</select>
我想将值发送到 Angular JS Controller 。
请帮忙
最佳答案
使用 ng-model 传递值:
app.controller('controllername',function($scope){
$scope.drpmodel=-1
$scope.cobchange=function(){
alert($scope.drpmodel);
}
});
<select class="form-control" id="cobSRQ2" ng-model="drpmodel" ng-change="cobchange()" required>
<option value="-1">[Select One]</option>
<option value="Primary" selected>Primary</option>
<option value="Secondary">Secondary</option>
<option value="Tertiary">Tertiary</option>
</select>
关于javascript - 使用静态值获取 AngularJS 中 ng-change 的下拉值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40762749/