Angular路由器正在从iframe捕获URL [英] Angular router is catching url from iframe
本文介绍了Angular路由器正在从iframe捕获URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个应该加载外部内容的iframe.问题是我的Angular应用程序托管在
I have an iframe that should load external content. The problem is that my Angular application is hosted on
http//mydomain
iframe加载的src网址是
And the iframe loads src url is
http://mydomain/external
出于CORS的原因,我确实需要将域设置为相同,因为我想操纵iframe内容.
I really need the domains to be the same for CORS reason because I want to manipulate the iframe content.
问题在于Angular路由器捕获了路由并引发了错误
The problem is taht Angular router catches the route and throws an error
Cannot match any routes. URL Segment: 'external'
我已通过以下方法对组件中iframe的网址进行了清理
I've sanitized the url of the iframe in my component with the following method
bypassSecurityTrustResourceUrl()
我不知道如何绕过角路由器或加载我的内容.
I don't know how to bypass angular router or to load my content.
任何帮助将不胜感激.
谢谢
推荐答案
我希望对您有所帮助.
HTML
<iframe class="iframeSomeStyle" [src]="safeUrl"></iframe>
Ts
safeUrlCheck(url) {
this.safeUrl = this.sanitizer.bypassSecurityTrustResourceUrl(url);
}
这篇关于Angular路由器正在从iframe捕获URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文