1

I am having an issue with encoding and decoding HTML Entities on a textarea using ngModel. The Back-End needs and is sending the ><"&' as HTML Entities. This seems like it would be easy to do this, but for the life of me I can't think of a straight/safe way to do it.

  1. I need to get the data from the Back-End and render the entities as normal text to the user.

  2. On save - I need to send back to the back-end the special characters of ><"&' as entities.

  3. Bonus if there is a way to do a blanket on all special characters - not needed, but why not.

    <textarea class="form-control" rows="5" id="comment" [(ngModel)]="employee.comments">

RooksStrife
  • 1,647
  • 3
  • 22
  • 54

1 Answers1

0

You can use innerhtml to load html content

<textarea class="form-control" rows="5" id="comment"  [innerHtml]="employee.comments" [(ngModel)]="employee.comments">

you can refer this for more information.

Similar query answer. Alternative way NPM Package