简体   繁体   中英

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 ?

尝试

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

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM