<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
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
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");
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.