0
<select name="Connection" id="dropConnection"  ng-change="connectionChange(this)" ></select> 

following is the script.

var app = angular.module('myApp', ['angular.filter']);
app.controller('customersCtrl', function($scope, $http) {

    function connectionChange(sel)
      {
        var connectionName = sel.options[sel.selectedIndex].text;
        alert("connectionName");
      }
});

Dropdown contents are added from json respose and its all working fine. The error is :

Uncaught ReferenceError: OnChange is not defined
    at HTMLSelectElement.onchange 
ajithes1
  • 433
  • 2
  • 11
  • 28

2 Answers2

1

you have to add the function in $scope like this

 $scope.connectionChange = function (sel){
    var connectionName = sel.options[sel.selectedIndex].text;
    alert("connectionName");
  }

also use ng-change for your html

Ghulam Mohayudin
  • 1,093
  • 10
  • 18
1

Not onchange but ng-change. See for more here ngChange. And remove your inner function

var app = angular.module('myApp', ['angular.filter']);
app.controller('customersCtrl', function($scope, $http) {
    var connectionName = sel.options[sel.selectedIndex].text;
    alert("connectionName");
});
Suren Srapyan
  • 66,568
  • 14
  • 114
  • 112