I have been thinking about something I find very counter-intuitive, I have found previous an issue about it, but information given in response is weak at best. https://github.com/angular/angular/issues/27826
A simplified explanation of what I am trying to accomplish. The issue is that I would like to create 2 areas, one that requires login and one that does not. When the user is logged in he have access to a special protected areas depending on his role (for simplicity lets say an admin section), the administration module is ONLY available if you have the correct system permission, and therefor I added a lazy-loaded module, with a canLoad property.
export const myRoute: Routes = [
{
path: '',
component: RequiresLoginComponent,
canActivate: [LoggedInGuard],
children: [
{
path: '',
component: ContentComponent,
},
{
path: 'admin',
canLoad: [PermissionGuard],
loadChildren: () =>
import('admin/admin.module').then((mod) => mod.AdminModule),
},
],
},
{
path: 'login',
component: LoginComponent,
},
];
if you visit /admin canLoad on child will ALLWAYS occur before canActivate, my routing is significantly more complicated than this, with nested sections of protected resources and sections. Can someone explain me the logic behind this design?