rahul aggarwal rahul aggarwal - 12 days ago 4
Javascript Question

get dropdown value on ng-change in angularjs with static values

I want to get value when I change the dropdown on ng-change. My code as follows:-

<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>


I want to send the value to Angular JS controller.

Please help

Answer

use ng-model for pass the value :

 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>
Comments