Mehmet Eren Yener
Mehmet Eren Yener

Reputation: 2036

Angular JS Conditional Css Class not working

Below the code gives output 15

<h1>{{model.ItemExpireAlertTime}}</h1>

however, when I tried to add conditional css class, it is not working for some reason.

<span timer interval="1000" countdown="item.ExpireTicksInSeconds">
   <span ng-class="minutes < model.ItemExpireAlertTime ? 'item-expire-alert' : '' " ng-show="minutes < 10">0</span>{{minutes}} dk 
   <span ng-show="seconds < 10">0</span>{{seconds}} sn
</span>

How can I add alert class when minutes is smaller than ItemExpireAlertTime ?

Upvotes: 0

Views: 70

Answers (2)

krishna
krishna

Reputation: 152

Try

ng-class="{'item-expire-alert': minutes < model.ItemExpireAlertTime}"

Upvotes: 2

muenchdo
muenchdo

Reputation: 2181

You have your ng-class the wrong way around, try this:

<span timer interval="1000" countdown="item.ExpireTicksInSeconds">
  <span ng-class="{'item-expire-alert': minutes < model.ItemExpireAlertTime}" ng-show="minutes < 10">0</span>{{minutes}} dk 
  <span ng-show="seconds < 10">0</span>{{seconds}} sn
</span>

Upvotes: 2

Related Questions