Home>

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

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:

1.mousedown

2.mouseup

3.click

grammar

<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