Im looking for a way to use one angular route resolve to use on all of my routes, but with different parameters:
currently, i have something like:
{
path: 'user/:any',
component: UserprofileComponent,
resolve: { ProfiledUser: UserprofileResolver }
},
profileuser resolve:
resolve(route: ActivatedRouteSnapshot) {
return this.GlobalService.Get('/userprofile/admin');
}
Im in fact looking for a way to use the parameters the Get
function from GlobalService
is using, for the resolver itself.
I have made something previously that could in theory work:
path: 'family/panel',
component: FamilyCoreComponent,
canActivate: [PermissionGuardService],
data: {roles: [0]},
where canactivate permission guard:
canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot):Observable<boolean>|boolean {
var requirementRole = next.data.roles[0];
So my question is, should i use the principle for the resolver, as i did to my permission guard?
For example something like:
{
path: 'user/:any',
component: UserprofileComponent,
resolve: { ProfiledUser: UserprofileResolver }
data: {load: 'userprofile/admin'},
},
Would this be a good way to do it? if so, how would i do it to make this the most efficient?