1

I have an app with the next routing structure:

{
    path: "home",
    component: HomeComponent,
    children: [
        {
            path: "list",
            component: ListViewComponent
        },
        {
            path: "dashboard",
            component: DashboardComponent
        },
        {
            path: '',
            pathMatch: 'full',
            redirectTo: 'dashboard'
        },
        {
            path: "**",
            redirectTo: 'dashboard'
        }
    ]
}

how I can check if the user navigates into the page by full path eg home/list or by redirectTo?

Taras Kovalenko
  • 2,323
  • 3
  • 24
  • 49

2 Answers2

2

You can check the url by adding:

path: 'team/:id',
component: TeamComponent,
canActivate: ['canActivateTeam']

Here ['canActivateTeam'] can be a function in a service.

rafi muhammad
  • 194
  • 2
  • 11
0

You can use state while navigating to the url and pass it a user defined value.

According to angular documentation:

Developer-defined state that can be passed to any navigation. Access this value through the Navigation.extras object returned from router.getCurrentNavigation() while a navigation is executing.

For more info refer: https://angular.io/api/router/NavigationExtras

sah1
  • 380
  • 1
  • 6
  • 23
  • is related to manual navigation, in my case I need to catch this by route config. – Taras Kovalenko Oct 01 '19 at 09:03
  • @TarasKovalenko You should be able to use data similarly. https://stackoverflow.com/questions/36835123/how-do-i-pass-data-to-angular-routed-components might help you – sah1 Oct 01 '19 at 09:43