如何重定向到 Angular2 中的外部 URL? [英] How to redirect to an external URL in Angular2?

查看:37
本文介绍了如何重定向到 Angular2 中的外部 URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 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屋!

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