Earlier when I didnt had separate module for profile I didn't have to place profileDetails resolver inside only the dashboard component parent route and in all my componets i am accessing profile details as follows
activeRoute.parent.data.subscribe((data)=> {
this.userDetail = data.profileDetails.data;
});
Now I need to put profile detail resolve in all the sub modules of dashboard module and every time I go inside the compolent the profile detail api in the network tab gets called 2 times instead of one. I think one is called from the dashboard routing module and other from the individual module like profile module in this case.
App routing module
path: 'dashboard',
loadChildren: './dashboard/dashboard.module#DashboardModule'
Dashboard Routing Module
const routes: Routes = [
{
path: '', component: DashboardComponent,
canActivate: [AuthGuard],
runGuardsAndResolvers: "always",
resolve: {
profileDetails: ProfileDetailsResolverService,
},
children: [
{
path: '',
loadChildren: './dashboard-home/dashboard-home.module#DashboardHomeModule'
},
{
path: 'my-profile',
loadChildren: './my-profile/my-profile.module#MyProfileModule'
}
Profile Routing Module (I have to place profile details resolve here and all the other components, is there a way to not put it here and access the resolve which is already placed in the dashboard routing module)
const routes: Routes = [
{
path: '', resolve: {
profileDetails: ProfileDetailsResolverService,
},
children: [
{
path: '', component: MyProfileComponent,
data: { title: 'Ddb | Profile' }
}
]
}
];