question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Does not work as root in lazy loaded module

See original GitHub issue

I’m submitting a…


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:

Current behavior

When loaded in root or directly connected module, it works fine but when loaded as lazy module there is a problem:

taticInjectorError(AppModule)[TranslocoService -> InjectionToken TRANSLOCO_TRANSPILER]: 
    StaticInjectorError(Platform: core)[TranslocoService -> InjectionToken TRANSLOCO_TRANSPILER]: 
      NullInjectorError: No provider for InjectionToken TRANSLOCO_TRANSPILER!
NullInjectorError: StaticInjectorError[I18nService -> TranslocoService]: 
  StaticInjectorError(AppModule)[TranslocoService -> InjectionToken TRANSLOCO_TRANSPILER]: 
    StaticInjectorError(Platform: core)[TranslocoService -> InjectionToken TRANSLOCO_TRANSPILER]: 
      NullInjectorError: No provider for InjectionToken TRANSLOCO_TRANSPILER!

Expected behavior

works not only as imported in static module

Minimal reproduction of the problem with instructions

same as https://github.com/ngneat/transloco/issues/152. I have also tried to use TranslocoService as an own provider from useFactory, but it is not used. Maybe the cause is provideIn: 'root'?

What is the motivation / use case for changing the behavior?

I am creating application/library which have translation module configured before usage. Configuration is not predefined, and may be different

Environment


Angular version: 8.2.14
transloco: 2.3.15


Browser:
- [x] Chrome (desktop) version 80.0.3987.122
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: v12.13.1
- Platform: windows

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:49 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
shaharkazazcommented, Apr 20, 2020

@Azbesciak no worries, just give an update as soon as you get the chance to check it and we will take it from there 🙂

0reactions
jdiemkecommented, Dec 16, 2022

This is in fact a real world problem that can happend in a micro frontend architecture where each remote needs to provide its own translations. Any chance to get micro frontend support where each micro frontend (lazy loaded module) can have its own transloco instance?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Access root services in Angular lazy loaded module
When the Angular router lazy-loads a module, it creates a new injector. This injector is a child of the root application injector.
Read more >
Lazy-loading feature modules - Angular
Because the new module is meant to be lazy-loaded, the command does not add a reference to it in the application's root module...
Read more >
Configuring Lazy Loaded Angular Modules - Thinktecture AG
This opens up the possibility to provide a config to the forRoot() function of the module. It is merely a static function that...
Read more >
Lazy Loading Angular Modules - Michele Stieven - Medium
Don't import LazyModule for any reason! If you do that, you'll lose all the advantages of lazy-loading and you may have serious problems...
Read more >
Lazy Loading in Angular – A Beginner's Guide to NgModules
Root Module · declarations: The components in this module. · imports: The modules that are required by the current module. · providers: The...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found