I'm working on an Angular project and I have my module like this :
{
path: 'cours/:categoryId/chapters/:chapterId',
component: ChaptersComponent},
},
{
path: 'cours/:categoryId/chapters/:chapterId/lessons/:lessonsId',
component: AppLessonComponent
},
And my question is: If in the AppLessonComponent I want to get the :categoryId
or the :chapterId
is it possible ? 'Cause when I use activitedRoute.snapshot.params
it only getting the :lessonsId
which is logical ... Thanks for helping me
CodePudding user response:
You can configure the router to make route params available to child route components with paramsInheritanceStrategy
import {RouterModule, ExtraOptions} from "@angular/router";
export const routingConfiguration: ExtraOptions = {
paramsInheritanceStrategy: 'always'
};
export const Routing = RouterModule.forRoot(routes, routingConfiguration);