BonJon
BonJon

Reputation: 799

How to set multiple class for an element

I am trying to set the ng-class with multiple conditions.

I have something like

<div ng-repeat="product in products">
<div ng-class="{showProduct: product.productName,
                deletedProduct: !product.productExist && product.productName.length && product.type!='expire',
                add:product.changeStatus,
                expire:product.type = 'expire' 
                } 
     ng-click="product.changeStatus = !product.changeStatus">{{product.productName}}
</div>
</div>

I have multiple conditional on my div. My problem is that I want to stop toggling the add class when the expire class name is used which is in product.type='expire' condition. Is there anyways to do this? Thanks a lot!

Upvotes: 0

Views: 40

Answers (1)

Henrik N
Henrik N

Reputation: 16274

A simple solution might be to handle this with CSS rules:

.add {
  // styling for things with just .add
}

.add.expire {
  // styling for things with .add AND .expire
}

Upvotes: 1

Related Questions