简体   繁体   中英

Angular9 router.navigate

If the website was enabled on the old browser, my goal is to redirect the page to one with information about it. For this I use the ngx-device-detector package. And for redirect I am using this.router.navigate which is not working. Does anyone know why url is not replaced? Even though the condition is met, nothing happens.

 if(this.browserName === 'Chrome' && this.browserVersion < 83) {
      this.router.navigate(['/pages/unsupported-browsers-component'])
    }
  }

This is part of routing module file

    {
      path: 'pages/unsupported-browsers-component',
      component: UnsupportedBrowsersComponent,
    },

The Navigate function needs to have a pathname without a slash at the start, or you can simply use the path too with slash giving the absolute or relative URL to your component in the NaviagteUrl method. Refer link: angular.io/api/router/Router#navigate

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM