0

I have an app that generates some data in a table, and each cell has a specific combination of background color and text color, given by its properties.

the code for that is a simple:

ng-style='{"background-color": lt.backgroundColor, "color": lt.textColor}'>

now I need to implement a print view, so only some elements get printed, but my main issue is that I need the colors to be printed, they are important, and for that usually I always added a !important to the css rule and it would get printed.

But this time, I have ng-style that is giving colors, so how on earth can I add !important inside a ng-style?

I tried: lt.backgroundColor+""+"!important" but it's not working,

hell, even ng-style='{"background-color": "#000 !important"....} is working, only if I remove the !important like:

ng-style='{"background-color": "#000"....}

leaving only the hex code, it shows in the print view correctly,

any solutions?

AJ-
  • 1,638
  • 1
  • 24
  • 49

1 Answers1

0

You need to interpolate your attribute:

ng-style='{"background-color": {{lt.backgroundColor}}+' !important', "color": {{lt.textColor}} }'>
Zooly
  • 4,736
  • 4
  • 34
  • 54
  • sadly that is not working :( I even tried to use " " instead of ' ' around !important, but won't work, and I tried to swap external '' with "", and use internally '', but nothing – AJ- Jun 28 '18 at 15:28
  • The point is not about simple or double quote, that's the same! The important thing is to interpolate your variables such as `lt.backgroundcolor` – Zooly Jun 28 '18 at 15:32
  • ok, but then what's the issue? the double curly brackets get a different color from the outside one (xcode), so maybe I can't use them like that? (typescript) – AJ- Jun 28 '18 at 15:39