2

Let's consider that I am getting a response (as below) from api

Response

{
  embedEmail: "\n<div style='text-align:left'>\n  <input \n    type=\"email\" \n    id=\"textboxID_4204617a-0b6b-4676-880c-be963ee6ce74\" \n    data-expression='9'\n  >\n  </input>\n  <small style=\"display: block; margin-top: 0.5rem; margin-bottom: 0.5rem; color: crimson\" \n  id=\"textBoxemailHelpId\">\n  </small>\n</div><br/>\n<script>\nconst textBoxHtmlInputElement_4204617a_0b6b_4676_880c_be963ee6ce74_email = this.document.getElementById('textboxID_4204617a-0b6b-4676-880c-be963ee6ce74');\nconsole.log('textBoxHtmlInputElement_4204617a_0b6b_4676_880c_be963ee6ce74_email:', textBoxHtmlInputElement_4204617a_0b6b_4676_880c_be963ee6ce74_email)\n</script>\n"
}

I am able to render the HTML content present in the embedEmail with the help of a pipe which usesDomSanitizer.bypassSecurityTrustHtml().

But the challenge I am facing here is, the content inside the <script></script> tags is not rendered.

How to overcome this behavior so that I could render the script?

Some background information on what I am trying to achieve with the above stuff:

I am having an application where one end-user (using angular) saves the Input fields & it's respective validations as a string (i.e., stringified some HTML with some inline CSS and JS) in the DB.

This saved content string needs to be retrieved back as normal HTML for another end-user (using .NET) with all the CSS and JS applied properly.

Any other suggestions appreciated, but request you to address the above query too...

1
  • 1
    You will have the answer here stackoverflow.com/questions/77328994/… . I also faced the same issue and the solution is not very easy or intuitive but there at least there is a workaround. Commented Nov 20, 2023 at 15:20

0

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.