'How to use If else condition in app-routing.module.ts

this is my app-routing .module.ts file which has some of authguard implemented for some routes.

const routes: Routes = [{
path: 'dashboard',
loadChildren: () =>
  import('.......').then(
    (m) => m.DashboardModule
  ),
canActivate: [AuthGuard],

} ]

I have some flag that need to be checked whether it is true or false if it's true then authguard will come into the picture so how do I use the if-else condition in app-routing.module.ts



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source