ng-mouseover event passing ‘this’ (self) reference to DOM not working. is there anyother way rather than using core javascript event?

I want to get ‘self DOM’ on mouse over event, so I am passing ‘this’ on ng-mouseover event but its not working. please refer below code.

<a href="#" ng-mouseover="console.log(this)" >Mouse over me!</a>

I want it work with angular js only.

Answer

Use $event:

<a href="#" ng-mouseover="mouseMe($event)" >Mouse over me!</a>

JS

$scope.mouseMe = function (event) {
    console.log(event);
};

For more information, see AngularJS Developer Guide – $event.

Leave a Reply

Your email address will not be published. Required fields are marked *