How to redirect to an external URL in Angular2?

Michael Oryl picture Michael Oryl · Dec 17, 2015 · Viewed 298.2k times · Source

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?

Answer

Dennis Smolek picture Dennis Smolek · Dec 17, 2015

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

This would change the page to whatever you want..