Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

<div [innerHTML]=.... not working with iframe html> in angular2 html inject

<div [innerHTML]="html"></div> isn't working when the html contains an Iframe. I've tried to do some security bypass with this.sanitizer.bypassSecurityTrustResourceUrl(..., but it still doesn't work.

Here's the demo with angular2 not injecting correctly.

like image 439
thouliha Avatar asked Jul 18 '16 21:07

thouliha


1 Answers

Working PLUNKER

You need to use bypassSecurityTrustHtml for that, and need to assign and use the sanitized html like this

this.html = this.sanitizer.bypassSecurityTrustHtml(this.html);
like image 155
Ankit Singh Avatar answered Sep 18 '22 00:09

Ankit Singh