Inject Style Declarations Using Hostbinding in Angular
You need to pass the same value you would add to an element like <div style="...">
and sanitize the styles
@HostBinding('style')
get myStyle(): SafeStyle {
return this.sanitizer.bypassSecurityTrustStyle('background: red; display: block;');
}
constructor(private sanitizer:DomSanitizer) {}
working demo