Е
Size: a a a
IL
E
YK
ДМ
S
MD
DB
{ path: ' ', component: DashboardComponent, children: dashboardRoutes, canActivate: [CheckRoleGuard] },внутри в хтмл стоит
<router-outlet></router-outlet>
дочерние маршруты выглядят так:const dashboardRoutes: Routes = [Я хочу сделать так, чтобы при переходе на главную, canActivate определил роль пользователя, и в зависимости от роли перенаправил на нужный маршрут
// User routes
{ path: 'schedule', component: ScheduleComponent, canActivate: [UserGuard] },
// Admin routes
{ path: 'world', component: WorldComponent, canActivate: [AdminGuard] },
];
canActivate() {
console.log('Проверка на роль');
if (this.authService.isLoggedIn !== true) {
this.router.navigate(['sign-in']);
}
if (localStorage.getItem('role') === 'admin') {
this.router.navigate(['/world']);
}
return true;
}
Но получаю бесконечный цикл, что я делаю не так, и куда копать?🧤K
MD
AS
M
Ln
Ln
И
Ln
AS
🧤K
ЕБ
Вキ