Reputation: 2393
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
?
Upvotes: 1
Views: 2376
Reputation: 400
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
Upvotes: 0
Reputation: 192
You can check the url by adding:
path: 'team/:id',
component: TeamComponent,
canActivate: ['canActivateTeam']
Here ['canActivateTeam'] can be a function in a service.
Upvotes: 2