Angular - route with multiple resolvers

I am trying to implement a route with multiple resolvers. I am using this example:

https://stackblitz.com/edit/angular-route-resolves-multiple-resolves?file=app%2Fapp-routing.module.ts

This example shows how to implement two resolvers for the same route:

{ path: 'news',
component: NewsComponent,
resolve: {
  news: NewsResolver, // first resolve
  alternativeNews: AlternativeNewsResolver // second resolve
}

}

What I need is to be able to send different data to each resolver. Here is how it's been implemented in my system:

    path: '',
    component: aComponent,
    resolve: { model: aResolver },
    data: { resolvedata: 'data' },

Here is aResolver, simplified:

export class aResolver {
constructor() {}

resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<any> {
    const moduleName = route.data.resolvedata;
 ....
}

}

I am trying something like this to get started with just one resolver:

resolve: {
        data: { resolvedata: 'data'},
        model: aResolver
    },

That does not work.

Please share your ideas.

Thanks



Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation