I'm trying to provide a resolve service via the new "providedIn" attribute.
This is a translations resolver which i use in a protected module:
import { Injectable } from '@angular/core';
import { Observable , pipe } from 'rxjs';
import {map} from "rxjs/operators";
//This is causing: "WARNING in Circular dependency detected:"
import {ProtectedModule} from "../../../protected/protected.module";
import { HttpHandlerService } from '../../http/http-handler.service';
@Injectable({
providedIn: ProtectedModule //Over here (I need the import for this line)
})
export class TranslationsResolverService {
constructor(private _httpHandlerService : HttpHandlerService) { }
resolve(): any {
//Do Something...
}
}
I declare the translations resolver service in the protected routing module:
import { NgModule } from '@angular/core';
import {RouterModule, Routes} from '@angular/router';
import {AuthGuard} from "../core/resolvers/auth/auth.guard";
import {TranslationsResolverService} from "./../core/resolvers/translations/translations-resolver.service";
const routes: Routes = [
{
path : 'app' ,
component: ProtectedComponent,
resolve : {
translations : TranslationsResolverService // <---- Over here - i can't remove that of course
},
canActivate: [AuthGuard],
]
}
];
@NgModule({
imports : [RouterModule.forChild(routes)],
exports : [RouterModule]
})
export class ProtectedRoutingModule { }
Because of the fact that i import (typescript import) the protected.module in the translations-resolver.service.ts in order to use it in the providedIn attribute i get a WARNING in Circular dependency detected:
path to translations-resolver.service.ts ->
protected/protected.module.ts ->
protected/protected-routing.module.ts ->
path to translations-resolver.service.ts
The 2nd path (marked) is added due to the "providedIn attribute.
I can fix this by just providing the translationsResolver as a NgModule provider (in the providers array) but i prefer it to be an injectable provider.
Any suggestions for solving this?
Aucun commentaire:
Enregistrer un commentaire