'Angular navigate to a sibling route?

How do I navigate from /login path to /monitor path using this.router.navigate? Similar question but doesn't work for me: How do I navigate to a sibling route? Thanks!


const routes: Routes = [
  {
    path: '', redirectTo: 'monitor', pathMatch: 'full',
  },
  {
    path: 'monitor',
    canActivate: [AuthGuard],
    children: [
      {
        path: '', redirectTo: 'dell', pathMatch: 'full'
      },
      {
        path: 'lenovo', component: lenovoMonitorComponent
      },
      {
        path: 'dell', component: dellMonitorComponent
      },
    ]
  },
  { path: 'login', component: LoginComponent, data: { title: 'Login' }, }
];


Solution 1:[1]

In your case after successful login, you can use the below code to navigate to the /monitor

this.router.navigate(['/monitor']);

Solution 2:[2]

Turns out it is not a routing problem. The answer here How do I navigate to a sibling route? should work.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Elikill58
Solution 2 Sky