localize-router icon indicating copy to clipboard operation
localize-router copied to clipboard

Cyclic dependency error by using three modules: LocalizeRouterModule, TranslateModule, TransferHttpCacheModule

Open bobsingor opened this issue 7 years ago • 10 comments

I need to use these three modules in my project: TranslateModule LocalizeRouterModule TransferHttpCacheModule

Somehow these are causing a cyclic dependency error. Also did a post on StackOverflow https://stackoverflow.com/questions/47510536/cyclic-dependency-error-transferhttpcachemodule-localizeroutermodule-translate

And created a plnkr to reproduce this issue: https://plnkr.co/edit/qlUQ866JzTa3JtFgSAIO?p=preview

Hope someone can help me solve this issue.

bobsingor avatar Nov 29 '17 08:11 bobsingor

It's interesting problem. I'll try to assist you as soon as possible. Not sure why your question got down-voted on stack overflow.

meeroslav avatar Nov 29 '17 09:11 meeroslav

@bobsingor @meeroslav this seems to be a conflict between HttpClientModule and TransferHttpCacheModule.

Take a look at this plunker https://plnkr.co/edit/7Plnvz?p=preview Still don't know the solution for this yet.

imsingh avatar Dec 04 '17 14:12 imsingh

Still don't know the solution for this yet.

I guess no. It working only if TranslateModule.forRoot() stay empty.

manzonif avatar Jan 03 '18 16:01 manzonif

I think this issue is related to AOT compiler.

I can avoid Cyclic dependency error using the following ParserLoader and setting the translate property before init method through Injector. The only problem is that the translate property in LocalizeParser need to be protected, not private.

export class ManualParserLoader extends LocalizeParser {

    constructor(private injector: Injector, location: Location, settings: LocalizeRouterSettings, locales: string[] = ['en'], prefix: string = 'ROUTES.') {
        
        super(null, location, settings);
        this.locales = locales;
        this.prefix = prefix || '';
    }

    load(routes: Routes): Promise<any> {
        return new Promise((resolve: any) => {
            this.translate = this.injector.get(TranslateService);
            this.init(routes).then(resolve);
        });
    }
}

I'm sure there is a better solution, any suggestion?

manzonif avatar Jan 12 '18 17:01 manzonif

any solution for solve this ?

MR-MAP avatar Mar 04 '18 12:03 MR-MAP

Same issue over here :(

elSuperRiton avatar Mar 26 '18 19:03 elSuperRiton

Need help for this one too

arthurhamon avatar Mar 27 '18 08:03 arthurhamon

I have the exact same problem, is there any solution to fix it ?

abuttez avatar Mar 28 '18 12:03 abuttez

Same issue, any solution ? :)

ChrisHendrX avatar Mar 28 '18 12:03 ChrisHendrX

up

neverlose-lv avatar Jul 24 '20 13:07 neverlose-lv