Search code examples
http-redirectangularangular2-routing

How to redirect to an external URL in Angular2?


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(), 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?


Solution

  • You can use this-> window.location.href = '...';

    This would change the page to whatever you want..