For example, the URL: www.example.com should load one module if the user is authenticated, else it should load a different module.
I have tried using guards, but it didn't work as I expect it to.
I am pretty new to Angular. It would be much appreciated if someone could write a sample routes array for demonstration. :)
If the user is not authenticated, I want my routes to work something like below:
{
path: '',
loadChildren: './home/home.module#HomeModule'
},
{
path: 'login',
loadChildren: './login/login.module#LoginModule'
},
{
path: 'register',
loadChildren: './register/register.module#RegisterModule'
}
Else, if the user is authenticated, I want my routes to work something like below:
{
path: '',
pathMatch: 'full',
redirectTo: '/dashboard'
},
{
path: 'dashboard',
loadChildren: './dashboard/dashboard.module#DashboardModule'
},
{
path: 'profile',
loadChildren: './user-profile/user-profile.module#UserProfileModule'
}