Reputation: 231
I have getting warning like this in my angular sample.
WARNING: sanitizing HTML stripped some content, see http://g.co/ng/security#xss
Stackblitz: https://stackblitz.com/edit/angular-e4otvr-mjm48m?file=app.component.ts
Some one please help me out of here.
Thanks in advance.
I have tried this solution.
Still warning occurs.
getCellContent(e): string {
if (e && e.targetCell.className.indexOf('e-valuescontent') > -1 ) {
template = '<input type="checkbox">'; //Here, you can append the html elements
}
else {
template = '';
}
return this.sanitizer.sanitize(SecurityContext.HTML, template) || '';
}
WARNING: sanitizing HTML stripped some content, see http://g.co/ng/security#xss
Upvotes: 0
Views: 2568
Reputation: 550
Have you tried this?
return this.sanitizer.bypassSecurityTrustHtml(template);
instead of
return this.sanitizer.sanitize(SecurityContext.HTML, template) || '';
Angular needs to trust the html you inserting through innerHTML. This bypassSecurityTrustHtml(template)
method will help. It worked for me. Let me know yours.
Upvotes: 1