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}
}
);
}
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";
}
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.
<a [href]="https://www.yourExternalURL.com">
我正在输入额外的字符,因为现在答案中至少需要 30 个字符。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.