我是 AngularJS 的新手。我有一个问题,为什么不ng-change
通过 $event?
HTML
<div ng-controller="foo">
<select ng-model="item" ng-options="opts as opts.name for opts in sels" ng-change="lstViewChange($event)" ng-click="listViewClick($event)"></select>
</div>
脚本
var myApp = angular.module('myApp', []);
angular.element(document).ready(function() {
angular.bootstrap(document, ['myApp']);
});
function foo($scope) {
$scope.sels = [{id: 1, name: 'a'}, {id: 2, name: 'b'}];
$scope.lstViewChange = function($event){
console.log('change', $event); //undefined
}
$scope.listViewClick = function($event){
console.log('click', $event); //object
}
}
看看这个小提琴http://jsfiddle.net/QfZZH/。Click
通过有效的 $event 但change
没有。有人可以解释这种行为吗?