[英]Ng -Style with Index
我有一些用ng-repeat创建的卡(带有类缩略图)。我想要的是更改每张卡的背景颜色。我使用ng-mouseenter
mouseenter并可以使用。但是所有卡都受背景颜色效果的影响。无法使用ng-repeat的索引属性。当鼠标处于活动状态时,只影响一张卡。
<div class="thumbnail" ng-style="venuescardColour" ng-mouseenter="changeVenuesColor($index,true)" ng-mouseleave="changeVenuesColor($index,false)">
$scope.changeVenuesColor = function(loc,bool) {
if(bool === true) {
$scope.venuescardColour = {background: 'red'};
} else if (bool === false) {
$scope.venuescardColour = {background: 'white'};
}
};
为什么不使用简单的CSS?
.thumbnail {
background: white;
}
.thumbnail:hover {
background: red;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.