Saturday, 31 August 2013

AngularJS - Why select drop down doesn't have $event on change

AngularJS - Why select drop down doesn't have $event on change

I am newbie to AngularJS. I have a question, why does select doesn't
passes the $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>
Script
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);
}
$scope.listViewClick = function($event){
console.log('click', $event);
}
}
Have a look at this fiddle http://jsfiddle.net/dkrotts/BtrZH/7/. Click
passes a event but change doesn't.

No comments:

Post a Comment