angularjs ng-mouseleave directive

angularjs example

Execute the expression when the mouse pointer leaves the element:

<! 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-mouseleave="count=count + 1" ng-init="count=0">move the mouse away from me!</div>
When the mouse moves away from the div element,The calculated variable "count" is automatically incremented by one.</p>

Definition and usage

The ng-mouseleave directive is used to tell angularjs what to do when the mouse is moved away from the html element.

The ng-mouseleave instruction does not override the element's native onmouseleave event. When the event is triggered,Both the ng-mouseleave expression and the native onmouseleave event will be executed.


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

All html elements support this directive.

Parameter value

value description
expression An expression executed when the mouse is moved over the element.

  • Previous The perfect realization of eight kinds of js focus carousel (Part 1)
  • Next Php use get_class_methods () function to get classification methods