0

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 ?

2
  • Why does ng-show have a conditional? sounds like something for the controller. Maybe try ng-if Commented Sep 29, 2015 at 9:46
  • @gerdi because there is a timer and countdown here, so if minutes are smaller than 10 min, first number will be 0 like 10:00 -> 09:59 -> 09:58 Commented Sep 29, 2015 at 9:49

2 Answers 2

2

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>
Sign up to request clarification or add additional context in comments.

Comments

2

Try

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.