It is a test div element. It is a test div element. It is a test div element.

Angular DomSanitizer.bypassSecurityTrustHtml not executing script tag inside html content

129 views Asked by At

I tried to use DomSanitizer.bypassSecurityTrustHtml, the html content looks as below:

<div>
  <div id="test-div">
    It is a test div element.
  </div>
  <script>
    function changeColor() {
      document.getElementById('test-div').style.background='red';
    }
    changeColor();
  </script>
</div>

Everything works here except the script tag code. Any leads are highly appreciated.

0

There are 0 answers