I have a requirement where based on role I need to activate to the route. Please find code below:
canActivate(): boolean {
if(this.login_token) {
this._Service.getUser(this.login_token).subscribe(
(data) => {
if(data.role === 'admin') {
return true;
}
});
} else {
return false;
}
}
And I have configured my route as shown below:
{path: 'user', children: childRoutes, canActivate: [AuthGuard]}
But even if my guards return to true still I am not able to route to user
route.
Please let me know if I am doing something wrong here. I have already explored lot of posts on SO to handle async call in guards but still no suucess