0

I'm trying to set two properties based on the condition. I have this code:

<tr [ngStyle]="user.current ? {'background-color' : '#002147', 'color': '#fff' } 
: {'background-color': 'transparent', 'color': black}" *ngFor="let user of users; index as i">
...

My problem is that it only sets the first property (background-color), nothing happens with the text color. Can you please help me? Thank you very much! Have a nice day!

  • 1
    You may only need to put quotes around `black`. Otherwise, it should work, as you can see in [this stackblitz](https://stackblitz.com/edit/angular-se91su?file=src%2Fapp%2Fapp.component.html). – ConnorsFan May 27 '20 at 15:51

1 Answers1

1

You should check and try other things, your code looks right.

  • Check if there is already a color set on your "tr" element with !important annotation
  • Try to switch color and background color to see what happen
  • Your forgot single quote on "color: black" properties

I hope this can help you

Soulm8
  • 58
  • 4