Οδηγία ng-mousedown του AngularJS

Ορισμός και χρήση

ng-mousedown Η εντολή ενημερώνει το AngularJS για τις ενέργειες που πρέπει να εκτελεστούν όταν πατηθεί το κουμπί του ποντικιού σε συγκεκριμένο στοιχείο HTML.

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 the expression 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 Execute the expression when the mouse button is clicked.