</>
Skip to content
AngularJS lessons (10/28)

AngularJS — Events

ng-click

<button ng-click="count = count + 1">Click me</button>
<p>Count: {{count}}</p>

<button ng-click="addItem()">Add Item</button>

ng-dblclick

<div ng-dblclick="handleDoubleClick()">Double click me</div>

ng-mouseenter/Leave

<div ng-mouseenter="highlight()" ng-mouseleave="unhighlight()">
  Hover me
</div>

ng-keydown/Up

<input ng-keydown="handleKeydown($event)">
<input ng-keyup="handleKeyup($event)">

ng-change

<input ng-model="name" ng-change="handleChange()">

Event Object

$scope.handleClick = function($event) {
  console.log('Event type:', $event.type);
  console.log('Target:', $event.target);
};

ng-submit

<form ng-submit="submitForm()">
  <input ng-model="data">
  <button type="submit">Submit</button>
</form>

Event.stopPropagation

$scope.stopPropagation = function($event) {
  $event.stopPropagation();
};

Mini Practice

  1. Handle click events
  2. Use keyboard events
  3. Handle form submission
  4. Access event object

Up Next

Continue with Forms — AngularJS forms.

Related Topics

Frequently Asked Questions about Events

What is Events in AngularJS?

Events is a fundamental concept in AngularJS. This lesson explains it step by step with clear examples, making it easy for beginners to understand.

How do I learn Events?

Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn Events.

Why is Events important in AngularJS?

Events is essential for AngularJS development. Understanding this concept will help you write better code and solve real-world problems more effectively.