Skip to content

Instantly share code, notes, and snippets.

@lsg-vtaran
Created June 9, 2023 08:08
Show Gist options
  • Save lsg-vtaran/07dce99a784001bad3e44b4adcec3721 to your computer and use it in GitHub Desktop.
Save lsg-vtaran/07dce99a784001bad3e44b4adcec3721 to your computer and use it in GitHub Desktop.
//app.component.ts
this.trustedHtml = this.sanitizer.bypassSecurityTrustHtml("<h1>html tag</h1><svg onclick=\"alert('bypassSecurityTrustHtml')\" style=display:block>blah</svg>");
//app.component.html
<p style="border:solid" [innerHtml]="trustedHtml"></p>
//result
<h1>html tag</h1>
<svg onclick="alert('bypassSecurityTrustHtml')" style="display:block">blah</svg>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment