So I want to display a html string in my template. To do this I use this in my html file:
<div [innerHTML]="myObject.string | safeHtml"></div>
Where safeHtml is a pipe to mark the html string as trusted, like explained here for example. This is my component.ts:
import { Component } from '@angular/core';
@Component({
    templateUrl: "my html file"
})
export class MyComponent {
    myObject;
    variable;
    constructor() {
        this.variable = "hello";
        this.myObject = {string: "text text <b [innerHTML]='variable | safeHtml'></b> text text" };
    }
}
Right now this is displayed in the <div>: text text text text. When I inspect this in my browser, there is an <b> tag also where it should be, but it's empty, like: <b [innerHTML]="variable | safeHtml"></b>.
I don't want to do something like this where myObject.string is:
"text text <b>" + this.variable + "</b>text text"
That's because myObject actually is in another component and it doesn't has a link to this.variable (I don't know if that's good practise).
Can anyone help me with this to display the variable within a html string? I hope I explained it good enough.
Thanks!
 
    