Router RedirectTo default does not fire event NavigationEnd

Viewed 1719

I am using Angular v6.1.0 and. My routing file here:

const routes: Routes = [
  {
    path: '', component: DashboardComponent, children: [
      { path: '', redirectTo: 'activity', pathMatch: 'full' },
      { path: 'activity', component: ActivityComponent },
      { path: 'recent-activity', component: RecentActivityComponent },
      { path: 'notification', component: NotificationComponent }
    ]
  },

];

And here is my code to subscribe navigation events:

router.events.subscribe((event: Event) => {
      if (event instanceof NavigationStart) {
        // Do something here
      } else if (event instanceof NavigationEnd) {
        // Do something here
      }
    });

When I use router.navigation the NavigationEnd is fired.
But If I go to /dashboard router and it will redirect to /dashboard/activity in above routing file, the event does not fired.

UPDATE Here is my example on StackBlitz
Just enter the domain without any path, the console only log '/' when redirect to login (I prefer to log '/login')

0 Answers
Related