peterbsmyth / ngx-breadcrumbs

Angular 4+ routing breadcrumbs
MIT License
60 stars 43 forks source link

Custom McBreadcrumbsResolver in lazy loading module #7

Open viros opened 6 years ago

viros commented 6 years ago

I have an app.component registered in app.module. Inside this component i use mc-breadcrumbs component. i have lazy module 'lazy.module' that has it's own routing configuration. Here i'm using custom breadcrumb resolver inherited from McBreadcrumbsResolver. CustomMcBreadcrumbsResolver added to providers for 'lazy.module'.

With this configuration i see next error: ERROR Error: Uncaught (in promise): Error: StaticInjectorError(AppModule)[CustomBreadcrumbsResolver]:

If i add CustomBreadcrumbsResolver to app.module the error is gone and it works as expected. The problem, that i don't want to add this service to main module(Angular resolvers work in this way).

altso commented 5 years ago

I am having the same issue. Would be nice to have a solution for that.

fakhreddine commented 4 years ago

You can resolve this issue by adding {providedIn :'root'} inside Injectable decorator your code will be like this : @Injectable({providedIn :'root'})