#-
5 messages · Page 1 of 1 (latest)
Sounds like a Route Guard to me, specifically a Can Activate guard
Basically a function inside your route config will decide which of the two routes to load. The function would sit on the "protected" route (the one requiring full initialization of the user profile) and would return true if all is well and ['/route/to/navigate/to'] if not
That could be implemented with a route guard. In this specific case, I question why each team has its own route. If a user can only see one team, then perhaps the /team route renders whatever that user needs to see, without having separate /red /blue or /yellow routes.
you can have this trick that can help you
{
path: '',
pathMatch: 'full',
children: [],
canActivate: [RedirectGuard]
},
where RedirectGuard will check you condition and redirect to the right route
@Injectable({ providedIn: 'root' })
export class RedirectGuard implements CanActivate {
constructor(private store: Store, private router: Router) {}
canActivate() {
return if(condition)
this.router.createUrlTree(['/team', 'blue'])
} else {
rthis.router.createUrlTree(['/team', 'red'])
}
);
}
}