Wednesday, April 1, 2015

ng-mouseup event

AngularJS provides various mouse events to track events raised by user interaction with the mouse like mousedown, mouseup, mouseover etc, in this post we shall see on how to handle the mouseup event using AngularJS

AngularJS provides ng-mouseup directive to handle mouse down events raised by the user, mouseup event can be handled by associating the ng-mouseup directive to an event handler function which passes the mouse event as a parameter.

The following example shows on how to use the ng-mouseup directive to handle mouseup events raised by the user.

<html ng-app="mouseUpApp">
<head>
    <meta charset="utf-8">
    <title>AngularJS - Basic</title>
    <script src="angular.min.js"></script>
    <script>
var app = angular.module('mouseUpApp', []);

function mouseUpController($scope) {
           $scope.HandleEvent = function (mouseEvent) {
                $scope.XPos = mouseEvent.pageX;
                $scope.YPos = mouseEvent.pageY;
                $scope.Event = mouseEvent.shiftKey;
              };
};
</script>
</head>
<body>
          <div ng-controller="mouseUpController">
                   <div style="width:100px; height:100px; border:1px solid #000000;" ng-mouseup="HandleEvent($event)"></div><br/>
                   mouseUp at Position : ({{XPos}}, {{YPos}}) <br/>
                   </div>
          </div>
</body>
</html>

Output:



Search Flipkart Products:
Flipkart.com

No comments: