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">

1
  • Use {{}} with pipe that removes unneeded caracters – Commented Jun 29, 2022 at 18:12

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.