Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  
  <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.6/angular.js"></script>
  <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.6/angular-aria.min.js"></script>
    
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body ng-app="app" ng-controller="MainCtrl as vm">
  <div>
    Click the div below, see the console says the $event is present as it should be. Then hit the "enter" or "space" keys and see that the $event is not present, but should be...
  </div>
  <div ng-repeat="item in vm.items">
    <div class="my-div" ng-click="vm.onClick($event, $index, item)">Click me {{$index}}!</div>
  </div>
</body>
</html>
 
var app = angular.module('app', ['ngAria']);
app.controller('MainCtrl', function MainCtrl() {
  var vm = this;
  vm.items = [1,2,3,4];
  vm.onClick = onClick;
  
  function onClick(event, index, item) {
    debugger;
    if (!event) {
      console.log('no event present, though it should be', event, index, item);
    } else {
      console.log('event is present as it should be', event, index, item);
    }
  }
});
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers