I have a component named FirstComponent and its location is in /hub/first. The hub-routing module has a check for each route and looks like this:
const routes: Routes = [
{
path: '',
canActivateChild: [HubGuard],
children: [
{
path: 'firstComponent,
This means that every '/hub' route will be checked by the HubGurad CanActivate function.
I also have a guard for the first component route that checks and conditions and if it doesn't exist it redirects it to '/hub/secondComponent'.
The problem that I am facing is that I can see that although I am routing within 2 components under the same HubModule the "canActivate" function is called again. Is there a way that I can route from the first component to the second one without reactivating the CanActivateChild guard?
You should just use
canActivate
instead ofcanActivateChild
guard. It check this route branch once you enter.