AngularJS ng-mousedown directive

Definition and Usage

ng-mousedown The instruction tells AngularJS what operation to perform when the mouse button is clicked on a specific HTML element.

AngularJS's ng-mousedown Directives do not override the original onmousedown event of the element, both will be executed.

The order of mouse clicks is:

  1. Mousedown (mouse press)
  2. Mouseup (mouse release)
  3. Click (click)

Example

Execute expressions when the mouse clicks:

<div ng-mousedown="count = count + 1" ng-init="count=0">Click me!</div>
<h1>{{count}}</h1>

Try It Yourself

Syntax

<element ng-mousedown="expression</element>

All HTML elements support.

Parameters

Parameters Description
expression An expression to be executed when the mouse button is clicked.