AngularJS ng-mousedownDirective

AngularJS 参考手册AngularJS Reference Manual


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>

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:

  1. Mousedown
  2. Mouseup
  3. 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.

AngularJS 参考手册AngularJS Reference Manual

Other Extensions