【发布时间】:2017-08-31 20:23:49
【问题描述】:
我正在使用 ng-repeat 创建一个报价列表。根据每个报价状态,它们应该具有不同的颜色,并且在激活时,它也应该具有不同的特定状态。活动逻辑运行良好,但现在发生的情况是它们都呈现为真,所以它们都是相同的颜色。如果您对此有任何其他想法,请随意。
这是我在渲染后检查时看到的:
ng-class="{'offer card-active-false card row text-left': currentOfferId === offer.id, 'offer card card-false row text-left': currentOfferId !== offer.id}" class="offer card card-true row text-left"
这是我在 HTML 上的内容:
<div ng-repeat="offer in $parent.offersList track by $index">
<button ng-click="$ctrl.setCurrentOffer(offer)">
<div ng-if="" ng-class="{'offer card-active-{{offer.status}} card row text-left': currentOfferId === offer.id, 'offer card card-{{offer.status}} row text-left': currentOfferId !== offer.id}">
//then I have my divs
</div>
</button>
</div>
CCS:
.card-true {
background-color: #00FF44;
}
.card-false {
background-color: #C4C4CC;
}
.card- {
background-color: yellow;
}
.card-active-true {
background-color: #fff!important;
border-color: #00FF44;
}
.card-active-false {
background-color: #fff!important;
border-color: gray;
}
.card-active- {
background-color: #fff!important;
border-color: yellow;
}
谢谢!
【问题讨论】:
-
是否需要
ng-if? -
没有。我删除了,但它没有改变任何东西。