I'm working on a scenario where the home
route needs to cater to both admin and user roles. Is there a way to dynamically display the UserComponent
if logged in as a user, and show the AdminComponent
if logged in as an admin?
This is my current setup:
const routes: Routes = [
{ path: 'login', component: LoginComponent },
{
path: 'home',
component: HomeComponent,
children: [
// Mix of user/admin paths for child routes
]
}
]
I was contemplating something like this, but I'm unsure how to access the service within the script:
component: this.userService.isAdmin ? AdminComponent : UserComponent,