Some more context around your code snippet would be helpful. Things like how it's declared in the class, where is this initialization happening, is it exposed as a public member of the class are relevant.
However, my guess is that Angular doesn't trust the HTML as "safe".
For my needs I had to create a pipe to handle binding HTML markup to the template:
import { Pipe, PipeTransform } from '@angular/core';
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
/**
* See link for more detail: https://stackoverflow.com/questions/39628007/angular2-innerhtml-binding-remove-style-attribute
*/
@Pipe({
name: 'safeHtml'
})
export class SafeHtmlPipe implements PipeTransform {
constructor(private sanitized: DomSanitizer) {}
transform(value: string, args?: any): SafeHtml {
if(value) {
return this.sanitized.bypassSecurityTrustHtml(value);
} else {
return 'Undefined HTML';
}
}
}
See the Angular docs for Dom Sanitizer or follow the the link to the other SO post in the code comment for more info.