Angular 2 打开静态页面 [英] Angular 2 opening a static page

查看:21
本文介绍了Angular 2 打开静态页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 angular 2 项目.我想在新窗口中打开服务器上可用的静态帮助文件.我试过 window.open(help/index.html).它导航到页面,但抛出有关未找到路由的错误.我还尝试在角度区域之外运行上面的代码,但没有任何区别.我怀疑当浏览器位置更改时,angular 会在下一个更改检测周期中检测到它并尝试路由到该 URL.可以做些什么来实现这一目标.

解决方案

您可以尝试利用 window.open() 方法,相当于锚标签中的 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");


working Plunker example

这篇关于Angular 2 打开静态页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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