Doe
Doe

Reputation: 163

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,
    },

Upvotes: 0

Views: 66

Answers (1)

Vinita
Vinita

Reputation: 115

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

Upvotes: 1

Related Questions