I am using more than one canActivateChild guards as shown below:
{path: 'admin', canActivateChild : [AdminAuthGuard, EmployeeAuthGuard], children: adminRoutes }
Below is definition of admin guard:
canActivateChild() : boolean {
const role = localStorage.getItem('role');
if(role === 'admin') {
return true;
}
else {
return false;
}
}
I have very similar employee guard where I am checking role as employee. The issue with above code is:
- If my first guard return false, second guard is not at all executed.
- If my first guard returns true and my second guard return false. The route is failing at that time as well.
NOTE: My guards are synchronous still I am facing this issue. Please let me know how can I resolve it?
The actual code is much more complex than this. This is just a sample code to get help.