在离子中改变背景div的有条件颜色

时间:2016-11-16 04:20:42

标签: angularjs ionic-framework ionic-view

我在循环中有这个列表,在Ionic框架中

<ion-list ng-repeat = "item in ritiri.rows |filter: {'entry_by' : currentuserID}" can-frag="false">
    <ion-item class="item-remove-animate item-icon-right" ng-click="ritiriview(item.id_ritiro);">
      <h2>{{item.numero_spedizione}}</h2>
      <p>{{item.rag_soc_mitt}}</p>
      <p>{{item.indirizzo_mitt}}</p>
      <p>{{item.localita_mitt}}</p>

      <i class="icon ion-arrow-right-b"></i>
      <ion-reorder-button class="ion-drag" on-reorder="move(note, $fromIndex, $toIndex)"></ion-reorder-button>
      <ion-option-button class="button-balanced icon-left ion-happy-outline" ng-click="ritirieff(item.id_ritiro)"> Effettua</ion-option-button>
      <ion-option-button class="button-assertive icon-left ion-trash-b" ng-click="mancatiritiri(item.id_ritiro)"> Rifiuta</ion-option-button>
    </ion-item>

  </ion-list>

如果item.id_stato == 13或14或15,我需要更改每个列出项目的div的颜色。 我怎么能做到这一点?

2 个答案:

答案 0 :(得分:3)

您可以尝试使用ng-class上的条件:

<强> HTML

<div ng-class="{'colored': item.id_stato == 13 || item.id_stato == 14 || item.id_stato == 15}">

<强> CSS

.colored {
    background: color-value;
}

答案 1 :(得分:0)

@ApiMethod(path = "myPath/{tokenId}/doSomething", httpMethod = "get")
    public ResponseMessage ReturnSomething(@Named("tokenId") String tokenId, User user)