如何在Angular2中重定向到外部URL? [英] How to redirect to an external URL in Angular2?
问题描述
在Angular 2中将用户重定向到完全外部URL的方法是什么?例如,如果我需要将用户重定向到OAuth2服务器以进行身份验证,我该怎么做?
What is the method for redirecting the user to a completely external URL in Angular 2. For example, if I need to redirect the user to an OAuth2 server in order to authenticate, how would I do that?
Location.go()
,Router.navigate()
和Router.navigateByUrl()
非常适合将用户发送到Angular 2应用程序内的另一部分(路由),但是我看不到如何将它们用于重定向到外部站点?
Location.go()
, Router.navigate()
, and Router.navigateByUrl()
are fine for sending the user to another section (route) within the Angular 2 app, but I can't see how they could be used to redirect to an external site?
推荐答案
您可以使用此-> window.location.href = '...';
这会将页面更改为您想要的任何内容.
This would change the page to whatever you want..
这篇关于如何在Angular2中重定向到外部URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!