【发布时间】:2018-08-29 01:44:39
【问题描述】:
这是我的组件
export class myComponent implements onInit {
private outageCount;
ngOnInit(){
....subscribe((data) => {
this.outageCount = Object.keys(data).length;
})
}
我需要在CONTENT之前将outageCount传递给我的css
:host ::ng-deep app-settings-panel {
&:before{
//content:"4";
content:attr(outageCount);
background: #941313;
position: absolute;
top: 3px;
left: 22px;
border-radius: 50%;
height: 13px;
width: 13px;
border: 1px solid #ffffff;
color: white;
font-size: 8px;
text-align: center;
line-height: 13px;
}
如何将 outageCount 值从我的组件传递给 css :before content.
任何建议将不胜感激!
【问题讨论】:
-
为什么不使用 ngClass 或 ngStyle 来设置基于 typescript 值的属性
-
@IzzoObella 我必须在 :host ::ng-deep app-settings-panel { &:before{} 中更改它。我该如何使用 ngStyle?
-
可能是
/deep/帮助你。在类名前添加/deep/
标签: css angular sass angular2-template