css - AngularJS 如何在使用 ng-style 时启用彩色打印 css?

标签 css angularjs ng-style print-css

我有一个在表格中生成一些数据的应用程序,每个单元格都有特定的背景颜色和文本颜色组合,由其属性指定。

代码很简单:

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/

相关文章:

javascript - angular-drag-and-drop-lists 拖动的元素消失(chrome)

css - View 不改变背景图像

angularjs - 如何在 ng-repeat 中更新 ng-style

css - 在phpstorm中配置css自动补全

CSS 内容特殊字符 : Hex vs normal character

javascript - Angular Directive(指令)中无法访问多个属性

javascript - 使用指令或 ng-click 更改 AngularJS 中的预览

Angular2 异常 : Can't bind to 'ngStyle' since it isn't a known native property

html - 从 .phone 元素中删除链接

html - 保持元素始终居中,侧边文本位于左侧