Angular2 innerHtml binding breaks data binding
问题 I am trying to bind to innerHtml while keeping data binding. This does not work (outputs {{myVar}}). @Component({ selector: "test", template: ` <div [innerHtml]="myHtml"></div> `, }) export class TestComponent{ title = "My Title"; myHtml: SafeHtml; constructor(private sanitizer: DomSanitizer){ this.myHtml = sanitizer.bypassSecurityTrustHtml("<h1>{{title}}</h1>"); } } In my real app, myHtml is the content of an SVG file (which is why I need to bypassSecurityTrustHtml ) and often changes, so