1

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

2 Answers 2

1

The term $event is used to access the value the directive passed to the method. Access the target property of the event object, for details of an event.

Sign up to request clarification or add additional context in comments.

Comments

1

From the Docs:

$event

Directives like ngClick and ngFocus expose a $event object 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.

— AngularJS Developer Guide - $event

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.