0

I would like to set different color backgrounds of a table row depending on the state of one of my data structures

I tried

<tr data-ng-repeat="shipping in shippings" data-ng-init="shippingIndex = $index" data-ng-class="{
  'bg-custom bg-danger': shipping.status == 'NONE',
  'bg-custom bg-warning-o': shipping.status == 'SENT',
  'bg-custom bg-warning': shipping.status == 'TRACK_LOST',
  'bg-custom bg-success': shipping.status == 'RECEIVED',
  'bg-custom bg-dark': shipping.status == 'NOT_SUPPORT_TRACK' }">
Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
  • Does this answer your question? [Dynamic class in Angular.js](https://stackoverflow.com/questions/14643836/dynamic-class-in-angular-js) and [Add Dynamic class name in angularjs](https://stackoverflow.com/questions/30332810/add-dynamic-class-name-in-angularjs) – Ramesh Rajendran Nov 07 '22 at 16:05

1 Answers1

0

You can try by using below code. 'bg-danger', 'bg-success' etc.. are include in your css page.

<tr class="bg-custom" data-ng-repeat="shipping in shippings" data-ng-init="shippingIndex = $index" data-ng-class="{
  'bg-danger': shipping.status == 'NONE',
  'bg-warning-o': shipping.status == 'SENT',
  'bg-warning': shipping.status == 'TRACK_LOST',
  'bg-success': shipping.status == 'RECEIVED',
  'bg-dark': shipping.status == 'NOT_SUPPORT_TRACK' }"> 
</tr>
Ranjan Singh
  • 123
  • 2
  • 9