< div [innerHTML] = ....无法使用iframe html>在angular2 html注入 [英] <div [innerHTML]=.... not working with iframe html> in angular2 html inject

查看:120
本文介绍了< div [innerHTML] = ....无法使用iframe html>在angular2 html注入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<div [innerHTML]="html"></div>不起作用.我尝试使用this.sanitizer.bypassSecurityTrustResourceUrl(...进行一些安全绕过,但仍然无法正常工作.

<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.

此处为演示,其中angular2无法正确注入.

Here's the demo with angular2 not injecting correctly.

推荐答案

> 正在使用PLUNKER

您需要为此使用bypassSecurityTrustHtml,并且需要分配和使用 像这样消毒html

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);

这篇关于&lt; div [innerHTML] = ....无法使用iframe html&gt;在angular2 html注入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆