jsverse / transloco

🚀 😍 The internationalization (i18n) library for Angular
https://jsverse.github.io/transloco/
MIT License
2.01k stars 195 forks source link

Does not work as root in lazy loaded module #253

Closed Azbesciak closed 4 years ago

Azbesciak commented 4 years ago

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            
Predhin commented 1 year ago

do we have any update on support for microfrontend based approach where the lazy loaded module needs to have access to the transloco context ? Thanks.