Does it matter where the resolver
exists in Angular in these two examples? Both of these two snippets of code achieve the same result:
Placing the resolver at the module-level within AppModule
:
const routes: Routes = [
{
path: 'user',
resolve: {
user: UserResolver
},
loadChildren: () => import('./user/user.module').then(m => m.UserModule)
},
];
vs. placing it directly on the component (with children routes) for the routing defined inside the UserModule
:
const routes: Routes = [
{
path: '',
component: UserComponent,
resolve: {
user: UserResolver
},
children: [
{
path: 'details',
component: DetailsComponent,
},
{
path: 'change-password',
component: ChangePasswordComponent,
},
],
},
];
What is the difference between resolving the data at the module level, vs. resolving it at the component level, with children
routes?