Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 4 route to external url

Tags:

angular

I am trying to get a route to an external URL. Below is my example so far.

The error I am getting is:

ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'https:/google.com'

Error: Cannot match any routes. URL Segment: 'https:/google.com'

here is my code

ViolatorLink() {
    this.router.navigate(['https://www.google.com/'], {
        queryParams: {mid: this.mid}
      }
    );
  }
like image 389
Alex D Avatar asked Jun 14 '18 17:06

Alex D


1 Answers

Ideally, you should use the window.location.href = "https://www.google.com"; for your external URL calls because this.router.navigate looks the URL in angular routings.

Your function should be like:

ViolatorLink() {
    window.location.href = "https://www.google.com";
  }
like image 170
Rohit.007 Avatar answered Sep 20 '22 10:09

Rohit.007