【发布时间】:2017-07-11 16:54:30
【问题描述】:
我有这个代码:
控制器:
var ratingTotal = 5;
$scope.count = 0;
$scope.getRepeater = function() {
return new Array(ratingTotal);
};
HTML:
<div>
<span ng-repeat="r in getRepeater() track by $index" ng-mouseover="count = count + 1" ng-mouseleave="count =count-1" ng-class="{'icon-star-full': ($index + 1) <= count, 'icon-star-empty': ($index + 1) >= count}"></span>
</div>
我试图通过将鼠标移到图标上来使图标开始完整显示,并在离开 div 时消失,但它不起作用
PD:icon-start-full 和 icon-start-empty 类是 icomoon 类
【问题讨论】:
-
这对您有帮助吗? using mouseover in angular
-
为什么不在鼠标悬停时将 count 设置为 $index(或
$index + 1,如果您的评分为 1-5 而不是 0-4)? -
@mhodges 如果我删除 mouseleave,它会像你说的那样工作,但我也想要 mouseleave
-
@DavidAlzate88 看看我的回答
标签: javascript angularjs html