How can I incorporate CSS text retrieved from the backend into my Angular component?
I attempted to use DomSanitizer's bypassSecurityTrustHtml method, but found that any included style tags were being escaped.
For instance:
import {BrowserModule, DomSanitizer} from '@angular/platform-browser'
@Component({
selector: 'the-app',
template: `
<div [innerHtml]="myHtml"></div>
`,
})
export class App {
constructor(private sanitizer: DomSanitizer) {
// The CSS text would typically be fetched from a database...
this.myHtml = sanitizer.bypassSecurityTrustHtml('<div><style>.myClass{color: red;}</style><div>THIS SHOWS FINE</div></div>') ;
}
}