AngularJS ngmouseup



  • ng-mouseup directive is used to specify the custom behavior that execute when a mouse click is finished on the specific HTML element.
  • In AngularJS, the ng-mouseup directive will not override the HTML element’s original onmouseup event, both will be executed.
  • The ng-mouseup directive is compiling at the priority level "0".(zero is a default priority level).
  • ng-mouseup is supported by all HTML element.

Syntax for ng-mouseup directive in AngularJS:

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

Parameter value for ng-mouseup directive in AngularJS:

Value Description
expression It is used to define an expression that execute when a mouse click is finished.

Sample coding for ng-mouseup directive in AngularJS:

 Tryit<!DOCTYPE html>
<html>
    <head>
        <title>Wikitechy AngularJS Tutorials</title>
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/
            angular.min.js"></script>       
    </head>
    <body ng-app="">
        <h2>ng-mouseup directive in AngularJs</h2> 
        <button ng-mouseup="count = count + 1" ng-init="count=0"> 
                Click here!    
        </button> 
        <h3> The mouseup count :{{ count }} </h3>
    </body>
</html>

Code Explanation for ng-mouseup directive in AngularJS:

Code Explanation for AngularJS ngmouseup

  1. AngularJS is distributed as a JavaScript file, and can be added to a HTML page with a <script> tag.
  2. The AngularJS application is defined by ng-app="". The application runs inside the <body> tag.It’s also used to define a <body> tag as a root element.
  3. The ng-mouseup= “count=count+1” is used to increase the count variable by one, every time the mouse click is finished on the button element.
  4. The ng-init="count = 0" is used to define the initial value of the count variable is 0.
  5. The {{ count }} is used to dynamically bind the count variable value when the mouse click is finished on the button element.

Sample Output for ng-mouseup directive in AngularJS:

    Sample Output for AngularJS ngmouseup

  1. The output displays that a mouse click is finished on a “Click here!” button and the content “The mouseupcount:1”. Here the variable “count” will be increased a value by 1, because only one time the mouse click is finished.

Related Searches to angularjs ng-mouseup directive