Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
bobsingor opened this issue Nov 29, 2017 · 10 comments

Comments

@bobsingor
Copy link

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.

@meeroslav
Copy link
Collaborator

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.

@imsingh
Copy link
Contributor

imsingh commented Dec 4, 2017

@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.

@manzonif
Copy link
Contributor

manzonif commented Jan 3, 2018

Still don't know the solution for this yet.

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

@manzonif
Copy link
Contributor

manzonif commented Jan 12, 2018

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?

@MR-MAP
Copy link

MR-MAP commented Mar 4, 2018

any solution for solve this ?

@elSuperRiton
Copy link

Same issue over here :(

@arthurhamon
Copy link

Need help for this one too

@abuttez
Copy link

abuttez commented Mar 28, 2018

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

@ChrisHendrX
Copy link

Same issue, any solution ? :)

@neverlose-lv
Copy link

up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants