[英]Is there any way to redirect to a basic html page from an angular2 component?
我有一个search.component.ts,我在这里根据搜索条件获取数据。 现在,我想根据我的搜索组件中的数据生成一个报告,该报告是基本的html页面,而不是search.component.html。 我希望在其他选项卡上打开html页面。 有什么合适的解决方案吗?
在模板中创建一个按钮:
<button type="button" (click)="redirect">Redirect</button>
在您的组件中创建一个函数:
redirect(){
window.open(
'https://support.wwf.org.uk/earth_hour/index.php?type=individual',
'_blank' // <- This is what makes it open in a new window.
);
}
PS。 一个简单的谷歌搜索发现window.open()函数接受第二个参数来打开一个新窗口。 看到链接JavaScript:location.href在新窗口/选项卡中打开?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.