0

my component class has string like this:

  text: string = "I am <button type='button' class='btn btn-link p-0 hashtag'
        (click)='searchHashtag(innerHTML)'>#happy</button> because I have 
  <button type='button' class='btn btn-link p-0 mention'>@sarah</button>";

and my html template has:

 <div class="container">
   <p [innerHtml] = "text"></p>
 </div>

The output I get is:

I am  because I have
georgeawg
  • 48,608
  • 13
  • 72
  • 95
  • Possible duplicate of [Angular HTML binding](https://stackoverflow.com/questions/31548311/angular-html-binding) –  Mar 18 '19 at 00:50

1 Answers1

0

You need to capitalize the HTML part of innerHtml.

<div class="container">
   <p [innerHTML]="text"></p>
 </div>