簡體   English   中英

有什么方法可以從angular2組件重定向到基本的html頁面嗎?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM