1

With the new standalone component, in Angular 15, we can now import dependencies directly in the @componentdeclaration.

We can also import only NgIf instead of the CommonModule to make our component more three-shakable.

But I was wondering how to import the innerHTML one.

Did somebody find it ?

I saw that the eDomAdapter had the createHtmlDocument method, but I cannot import that

Matthieu Riegler
  • 31,918
  • 20
  • 95
  • 134
Raphaël Balet
  • 6,334
  • 6
  • 41
  • 78

2 Answers2

2

innerHtml is not a directive, it a native attribute of Element. There is nothing to import.

Matthieu Riegler
  • 31,918
  • 20
  • 95
  • 134
0

You can use innerHtml like this without importing anything, HTML File:

<div [innerHTML]="htmlStr"></div>

Typescript File:

htmlStr: string = 'Plain Text Example &amp; <strong>Bold Text Example</strong>';
AliRhz
  • 39
  • 4