Reputation: 277
I'm using the DomSanitizer function bypassSecurityTrustHtml() for sanitizing.
Upvotes: 1
Views: 12154
Reputation: 71911
The value is stored in a changingThisBreaksApplicationSecurity
property. Which probably says enough to not use it.
const safeHtml = this.domSanitizer.bypassSecurityTrustHtml('<div>hello</div>');
const html = safeHtml['changingThisBreaksApplicationSecurity'];
// html === <div>hello</div>;
However, you should only use the sanitizer and the value returned inside your template:
<div [innerHTML]="safeHtml"></div>
Now the div will have the contents of the html passed into the bypassSecurityTrustHtml
Upvotes: 4