我有一个在表格中生成一些数据的应用程序,每个单元格都有特定的背景颜色和文本颜色组合,由其属性指定。
代码很简单:
ng-style='{"background-color": lt.backgroundColor, "color": lt.textColor}'>
现在我需要实现一个打印 View ,所以只打印了一些元素,但我的主要问题是我需要打印颜色,它们很重要,为此通常我总是添加一个 !important
添加到 css 规则,它将被打印出来。
但是这一次,我有 ng-style 给颜色,
那么我到底该如何在 ng 样式中添加 !important
呢?
我试过:lt.backgroundColor+""+"!important"
但它不起作用,
hell ,甚至 ng-style='{"background-color": "#000 !important"....}
正在工作,只有当我删除 !important 时:
ng-style='{"background-color": "#000"....}
只留下十六进制代码,它在打印 View 中正确显示,
有什么解决办法吗?
最佳答案
您需要插入您的属性:
ng-style='{"background-color": {{lt.backgroundColor}}+' !important', "color": {{lt.textColor}} }'>
关于css - AngularJS 如何在使用 ng-style 时启用彩色打印 css?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51085822/