Answer the question
In order to leave comments, you need to log in
Why is the method called before the end of resolve and so many times?
There is such a resolve:
export class PermissionResolver implements Resolve<any> {
constructor(private authService: AuthorizationService, private permissionService: PermissionService) { }
resolve(
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot
): Observable<any> | Promise<any> | any {
return this.authService.authorize().pipe(tap(() => {
this.permissionService.currentUser = this.authService.currentUser;
}));
}
}
const appRoutes: Routes = [
{
path: '', component: HomeComponent, pathMatch: 'full', resolve: { data: PermissionResolver }
}
];
<li class="nav-item"><a class="nav-link" [ngClass]="{'disabled':!permissionService.canView()}"
<body>
<nav-menu></nav-menu>
<router-outlet></router-outlet>
</body>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question