在我的HTML中,我使用的是:
<object #homes style="height:500px;width:1000px" data="{{homesPath}}"></object>
在TS:
constructor(
private homesProfileService: HomesProfileService,
private sanitizer: DomSanitizer) {}
this.homesPath = this.sanitizer.bypassSecurityTrustResourceUrl(
environment.homesPath
);
但是它给出了错误:
错误:资源URL上下文中使用的不安全值(请参阅 http://g.co/ng/security#xss)
我有什么不对的。
答案 0 :(得分:1)
现在通过更改HTML中的一点来实现它的工作:
<object #homes style="height:500px;width:1000px" data="{{homesPath}}"></object>
TO:
<object #homes style="height:500px;width:1000px" [data]="homesPath"></object>
但仍然没有得到前一个不起作用的原因。 任何人都可以评论它。