Ng-mouseenter directive call the mouseDown($event) function which calculates X and Y cordinate that is assign to the ng-style of div element.The position of div element change according to coordinates when we enter the mouse on the div element.

<!DOCTYPE html> <html xmlns=""> <head> <title></title> <script src=""></script> </head> <body ng-app="app"> <div ng-controller="controllerName"> <p>Mouse Enter on the square</p> <div ng-style="{'backgroundColor':'tomato', 'margin-top':X+'px', 'margin-left':Y+'px',width:'200px',height:'200px' }" ng-mouseenter="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 - 100; $scope.Y = event.clientY - 100; } }]); </script> </body> </html>