![](/img/trans.png)
[英]Uncaught ReferenceError: function is not defined with onchange
[英]Javascript . Uncaught ReferenceError: OnChange is not defined
<select name="Connection" id="dropConnection" ng-change="connectionChange(this)" ></select>
以下是脚本。
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");
}
});
下拉内容从json respose添加,并且一切正常。 错误是:
Uncaught ReferenceError: OnChange is not defined
at HTMLSelectElement.onchange
您必须像这样在$ scope中添加函数
$scope.connectionChange = function (sel){
var connectionName = sel.options[sel.selectedIndex].text;
alert("connectionName");
}
也为您的html使用ng-change
不是onchange
而是ng-change
。 在此处查看更多信息ngChange 。 并删除您的内部功能
var app = angular.module('myApp', ['angular.filter']);
app.controller('customersCtrl', function($scope, $http) {
var connectionName = sel.options[sel.selectedIndex].text;
alert("connectionName");
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.