What exactly $event in angularjs does? Suppose I pass it in a function from the template, what all properties can I use in the controller? I have used it in a few cases but have not understood what exactly it does.
2 Answers
From the Docs:
$event
Directives like
ngClickandngFocusexpose a$eventobject within the scope of that expression. The object is an instance of a jQuery Event Object when jQuery is present or a similar jqLite object.
Common Event Properties
jQuery normalizes the following properties for cross-browser consistency:
- target
- relatedTarget
- pageX
- pageY
- which
- metaKey
The following properties are also copied to the event object, though some of their values may be undefined depending on the event:
altKey, bubbles, button, buttons, cancelable, char, charCode, clientX, clientY, ctrlKey, currentTarget, data, detail, eventPhase, key, keyCode, metaKey, offsetX, offsetY, originalTarget, pageX, pageY, relatedTarget, screenX, screenY, shiftKey, target, toElement, view, which
For more information, see jQuery API Reference - Event Object