Using a custom loader in for transloco in route provider

169 Views Asked by At

In my route I want to use a custom loader that uses a service to fetch translations.

// router
  {
    path: 'dashboard',
    loadChildren: () => import('@org/dashboard').then((m) => m.DashboardRoutes),
    providers: [
      provideTranslocoScope({
        scope: 'dashboard',
        loader: loader,
      }),
    ],
  },
// loader
const loader: InlineLoader = (translations: TranslocoService) => {
  return lastValueFrom(translations.getTranslation());
};

getTranslation() retuns a Observable<Translation> But I see this error:

Type '(translations: TranslocoService) => Promise<Translation>' is not assignable to type 'InlineLoader'.
  Index signature for type 'string' is missing in type '(translations: TranslocoService) => Promise<Translation>'.
0

There are 0 best solutions below