AngularJS ng-mousedownDirective
AngularJS Example
Execute an expression when the mouse button is pressed:
<div ng-mousedown="count = count + 1" ng-init="count=0">Click me!</div>
<h1>{{count}}</h1>
<h1>{{count}}</h1>
Try it Yourself »
Definition and Usage
ng-mousedownThe directive tells AngularJS what to do when the mouse is pressed down on the specified HTML element.
ng-mousedownThe directive does not override the element's native onmousedown event. When the event is triggered,ng-mousedownboth the expression and the native onmousedown event will be executed.
Order of execution for mouse click:
- Mousedown
- Mouseup
- Click
Syntax
<element ng-mousedown="expression"></element>
All HTML elements support this directive.
Parameter Value
| Value | Description |
|---|---|
| expression | The expression to execute when the mouse is clicked. |
Other Extensions
AngularJS Reference Manual