我正在用ng-repeat創建商品列表。根據每個報價狀態,它們應該具有不同的顏色,並且在激活時它應該具有不同的特定狀態。主動邏輯運行良好,但現在發生的事情是,它們都呈現爲真實,因此它們都是相同的顏色。如果您有任何其他想法,請隨時聯繫。不同風格的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'需要的? –
沒有。我刪除了,但沒有改變任何東西。 –