5
我是AngularJS的新手。我有一個問題,爲什麼ng-change
沒有通過$事件?
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
通過有效的$事件,但change
不通過。有人可以解釋這種行爲嗎?