In the past, I ran into problems with IE and the css: hover selector, so the approach I took is to use a special directive.
.directive('hoverClass', function () { return { restrict: 'A', scope: { hoverClass: '@' }, link: function (scope, element) { element.on('mouseenter', function() { element.addClass(scope.hoverClass); }); element.on('mouseleave', function() { element.removeClass(scope.hoverClass); }); } }; })
then in the element itself you can add a directive with the names of the classes that you want to include when the mouse is over the element, for example:
<li data-ng-repeat="item in social" hover-class="hover tint" class="social-{{item.name}}" ng-mouseover="hoverItem(true);" ng-mouseout="hoverItem(false);" index="{{$index}}"><i class="{{item.icon}}" box="course-{{$index}}"></i></li>
This should add guidance and hue to the class when the mouse is over the element, and does not pose a risk of collision of the name of the variable scope. I have not tested, but the mouseenter and mouseleave events should still appear before the containing element, so this script should still work in this scenario
<div hover-class="hover" data-courseoverview data-ng-repeat="course in courses | orderBy:sortOrder | filter:search" data-ng-controller ="CourseItemController" data-ng-class="{ selected: isSelected }">
ensuring, of course, that li are children of the parent div
Warrenn enslin Jan 18 '14 at 16:49 2014-01-18 16:49
source share