Staafsak Staafsak - 1 year ago 170
Javascript Question

Angular JS Change Class on ng-mouseover

Am trying to add a class (blue) to a button when ever you hover the button using AngularJS.


<button class="btn-add-optimize" ng-mouseover="hover(iets)">Add and Optimize</button>


$scope.hover = function (iets) {
var Dit = this;

Anyone can help me out? Preferable a small example, it would be very appreciated!

Answer Source

I've used something like this with success:

    ng-mouseleave="hovering=false">Add and Optimize</button>

Entering and leaving the button toggles $scope.hovering, and the application of some-class is contingent on the $scope.hovering scope variable being true.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download