0

I have 4 templates, each of them has mouse actions:

ng-mouseover="enableDragging()" ng-mouseleave="disableDragging()"

Inside those functions, I change some scope variable and I want to be able to add a class using jQuery. Can I do it without passing a parameter and without updating some scope variable (or some other workaround).

What I mean is some plain way of using a class or id located in all 4 templates, without naming which template I'm on.

Incase perhaps I'm going about it the wrong way the story is: I want to change some scope variable AND the css of a div when entering that div, and rollback that change when I leave the div.

Thanks

1 Answer 1

2

Pass $event as a parameter to ng-mouseover callback function to get the element reference.

ng-mouseover="enableDragging($event)"

in controller

function enableDragging(event){
  var element = event.target;
  console.log(element)
}

If you want to update the class of Dom node based on a condition, you can try ng-class directive.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.