在应用程序Angular2外部进行路由 [英] Routing outside of application Angular2
本文介绍了在应用程序Angular2外部进行路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Angular2中有一个应用程序,需要导航到该应用程序之外. 我有一个简单的看法:
I have an app in Angular2 and I need to navigate outside of app. I Have simple view:
...
<a [routerLink]="library.url" target="_blank" (click)="goToPage(library.url)">{{library.url}}</a>
...
,我想导航到library.url
,我有导航方法:
and I want to navigate to library.url
, I have method for navigation:
goToPage(url: string)
{
//What should be here for navigation outside?
}
还是存在另一种方法?
推荐答案
您可以在代码中设置浏览器的全局窗口位置,以导航至您的网址:
you can set the global window-location of your Browser in your code, to navigate to your url:
goToPage(url: string): void {
window.location.href = url;
}
这篇关于在应用程序Angular2外部进行路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文