0

bold function doesn't work in Typescript

Hello, so I'm working on Angular project and I have a function in a typescript file that bold a specific part

      formatText() {

      ...........
      

      new_text = part1 +  word.bold()  + part2;

      return new_text;

  }

then I called I returned in an HTML file

                <div *ngFor="let sentence of sentences">
                <li>
                    {{formatText()}}
                </li>
               </div>

However what I get is the tags instead of bolding the word like this:

A young college teacher <b>leaves</b> China for the United States in search of a better future.
deepakchethan
  • 5,240
  • 1
  • 23
  • 33
no thanks
  • 63
  • 10

1 Answers1

0

Try surround formatText() with <p> tag in your HTML:

<div *ngFor="let sentence of sentences">
      <li>
            <p>{{formatText()}}<p>
      </li>
</div>

Hope this would help

Minor suggest: <li> tag should be inside <ul> tag