如何使用angular Router导航到外部URL

时间:2020-08-20 17:26:57

标签: angular routes angular-routing

我被困在这里很久了。如何替换window.location.href = url以使用Angular路由?

checkforStoredLocale() {
  if (this.storedlocale && this.storedlocale !== this.localeId) {
    this.consoleService.consoleMessage('redirecting');
    let port = this.location.port.length > 0 ? `:${this.location.port}` : '';
    let url = `${this.location.protocol}//${this.location.hostname}${port}${this.baseHref}${this.storedlocale}${this.location.pathname}`;
    this.consoleService.consoleMessage(url);
    // this.route.navigateByUrl(url);
    window.location.href = url;
  }
}

0 个答案:

没有答案