I am working on angular 5 application, and I have requirement of applying dynamic css in style tag in template. I have tried some solutions but they are not working.
app.component.ts
customCss : any;
constructor(){}
ngOnInit(){
this.customCss['color'] = "red";
}
app.component.html
<div>
<span class="custom_css">This is angular 5 application</span>
</div>
<style>
.custom_css{
color: {{customCss.color}};
}
</style>
When I inspect the custom_css class in browser then in style it shows
.custom_css{
color: {{customCss.color}};
}
Any help is appreciated.
stylein template. But it's easy to create dynamic element.