Reputation: 828
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}
}
);
}
Upvotes: 6
Views: 21697
Reputation: 7199
<a [href]="https://www.yourExternalURL.com">
I am typing extra characters because SO now needs at least 30 characters in an answer.
Upvotes: -4
Reputation: 3502
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";
}
Upvotes: 9
Reputation: 222552
You need to use instead of this.router.navigate
window.location.href = "https://www.google.com";
this.router.navigate
will navigate to only the elements configured in your router config module. So you are getting the error above.
Upvotes: 5