This article mainly introduces the angularjs ng-mousedown instruction.Here we have organized the basic information of the ng-mousedown instruction.With code examples,Have

angularjs ng-mousedown directive

angularjs example

Execute the expression when the mouse is pressed:

<! Doctype html>
<meta charset="utf-8">
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script>
<body ng-app="">
<div ng-mousedown="count=count + 1" ng-init="count=0">click me!</div>
<p>This example demonstrates that when the mouse is pressed over a div element,The calculated variable "count" is automatically incremented by one.</p>

Definition and usage

The ng-mousedown directive is used to tell angularjs what to do when the mouse is pressed on the specified html element.

The ng-mousedown directive does not override the element's native onmousedown event. When the event is triggered,Both the ng-mousedown expression and the native onmousedown event will be executed.

Mouse click execution sequence:





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

All html elements support this directive.

Parameter value

value description
expression An expression executed when the mouse is clicked.

  • Previous When the parameter value passed in the url contains&, the solution to the problem of automatic truncation of the url
  • Next A complete example of the placeholder effect implemented by jQuery