Home > Software engineering >  Navigate to url after subscribe Angular
Navigate to url after subscribe Angular

Time:11-05

I see a lot of same questions with mine, but none of them worked for me. So I am trying to navigate to the url after successful subscribing, but it is not navigating to url instead it is again redirecting to beginning.

private moveToOverview(): void {
  this.userService.reloadUser().subscribe(() =>  { this.router.navigate(['/wallet'])});
}

If I console the data .subscribe((data) => {console.log(data); // and then navigate to the url}), it is logging the data but not navigating.

CodePudding user response:

Try "navigateByUrl" instead of "navigate" and make sure your path is correct

CodePudding user response:

private moveToOverview(): void {
  this.userService.reloadUser().subscribe((data) =>  { this.router.navigate(['/wallet'])});
}
  • Related