我有這樣的代碼:嘗試改變NG-類NG-鼠標懸停和NG-鼠標離開
控制器:
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:class icon-start-全和圖標啓動空是icomoon類
這是否幫助你嗎? [使用鼠標懸停在角度](http://stackoverflow.com/questions/22532656/ng-mouseover-and-leave-to-toggle-item-using-mouse-in-angularjs) – Soorena
爲什麼不只是設置計數等於$在鼠標懸停的情況下索引(或者'$ index + 1',如果你的評分爲1-5而不是0-4)? – mhodges
@mhodges它如你所說,如果我刪除mouseleave,但我也想mouseleave – DavidAlzate88