问题描述
我有 angular 2 项目.我想在新窗口中打开服务器上可用的静态帮助文件.我试过 window.open(help/index.html)
.它导航到页面,但抛出有关未找到路由的错误.我还尝试在角度区域之外运行上面的代码,但没有任何区别.我怀疑当浏览器位置更改时,angular 会在下一个更改检测周期中检测到它并尝试路由到该 URL.可以做些什么来实现这一目标.
您可以尝试利用 方法,相当于锚标签中的 target
属性.
window.open("help/index.html", "_blank");
工作 Plunker 示例
I have angular 2 project. I want to open static help files available on server in new window. I tried window.open(help/index.html)
.It navigates to the page but throws error about route not found.I have also tried to run above code outside angular zone but makes no difference.I suspect as browser location changes angular detects it in next change detection cycle and try to route to that URL.What could be done to achieve this.
You could try and leverage the name
parameter of the window.open()
method which is the equivalent of the target
attribute in anchor tags.
window.open("help/index.html", "_blank");
这篇关于Angular 2 打开静态页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!