"No provider for InjectionToken SHORTNAME" error if I use ngx-disqus in any lazy loading module
Closed this issue · 7 comments
I get the error:
Error: StaticInjectorError(AppModule)[InjectionToken SHORTNAME]: StaticInjectorError(Platform: core)[InjectionToken SHORTNAME]: NullInjectorError: No provider for InjectionToken SHORTNAME!
Without lazy loading it works as expected.
Reproduction:
https://github.com/kodwi/abc
Some similar issue, looks like solved, maybe will help to solve the problem faster.
Please add reproduction, it works fine in here
Now try to include the DisqusModule in lazy one, not in AppModule, and check it out.
Wait, to use the DisqusModule in some another lazy loading module do I need to include it in AppModule with forRoot first, and then include it in that module?
If you import DisqusModule
in the root module, then you don't need to use forRoot
in the lazy module, but if you only import in lazy module, then forRoot()
must be called to initialize the shortname value
Having the same issue - doesn't look fixed. Importing the DisqusModule.forRoot() in a lazy loaded module gives the shortname error. (Angular 7, only when built and deployed)
-- Edit: Can confirm this only occurs on a lazy loaded module.
Yes, even using forRoot on the lazy module.
@stephengardner In v2.4.3 The token DISQUS_SHORTNAME
can be imported, in other word you can set the shortname in the root module while lazy load DisqusModule
in your feature module
Example:
In root module
import { DISQUS_SHORTNAME } from 'ngx-disqus';
@NgModule({
providers: [
{ provide: DISQUS_SHORTNAME, useValue: 'shortname_value' }
],
bootstrap: [AppComponent]
})
export class AppModule { }
In feature module
import { DisqusModule } from 'ngx-disqus';
@NgModule({
imports: [
// ...
DisqusModule
]
})
export class FeatureModule { }
Please try it with 2.4.3 and let me know if your issue is solved!