这是我的组件
export class myComponent implements onInit {
private outageCount;
ngOnInit(){
....subscribe((data) => {
this.outageCount = Object.keys(data).length;
})
}
我需要先将 outageCount 传递给我的 cssCONTENT
: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 :beforecontent
.
任何建议,将不胜感激!
我将其作为属性传递到我的 html 中,如下所示
[attr.outage-count]="outageCount"
我的css,我是这样更新的
:host ::ng-deep app-settings-panel {
&:before{
content: attr(outage-count);
......
}
}
这对我有用!感谢所有尝试帮助我的人!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)