Ng-Mousedown-2

 

In this example of Ng-Mousedown directive when your mouse button pressed in the sqaure then the co-ordinates of the mouse position will show below it as soon as the mouse down event fire.

 
 
 
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script> </head> <body ng-app="app"> <div ng-controller="controllerName"> <p>Mouse Down on the square</p> <div style="width:100px;height:100px; background-color:gray;" ng-mousedown="mouseDown($event)"></div> <pre ng-show="X">Mouse enter at:{{X}},{{Y}}</pre> </div> <script> var app = angular.module("app", []); app.controller('controllerName', ['$scope', function ($scope) { $scope.mouseDown = function (event) { $scope.X = event.clientX; $scope.Y = event.clientY; } }]); </script> </body> </html>
Output