This is my component
export class myComponent implements onInit {
private outageCount;
ngOnInit(){
....subscribe((data) => {
this.outageCount = Object.keys(data).length;
})
}
I need to pass the outageCount to my css before CONTENT
: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;
}
How can i pass the outageCount value from my component to css :before content
.
Any suggestions would be appreciated!
Sometimes you need to share variables between CSS (or SCSS) and Typescript, for example, if you have a list of colors in your SCSS file and need to check the variable names in typescript to be sure is an available color.
I'm passing this as attribute in my html like below
[attr.outage-count]="outageCount"
I css, i updated like this
:host ::ng-deep app-settings-panel {
&:before{
content: attr(outage-count);
......
}
}
This works for me!! Thanks for all those who tried helping me!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With