Getting error: StaticInjectorError(Platform: core)[InjectionToken ToastConfig] in angular 8
See original GitHub issueHi Guyz,
Thank you for such a great package.
I have ngx-toastr package installed on my project but I am not using it right now. so I have no export that module in my app component. Once I run the application I am getting this error:
core.js:4002 ERROR Error: Uncaught (in promise): NullInjectorError: StaticInjectorError(AppModule)[InjectionToken ToastConfig]: StaticInjectorError(Platform: core)[InjectionToken ToastConfig]: NullInjectorError: No provider for InjectionToken ToastConfig! NullInjectorError: StaticInjectorError(AppModule)[InjectionToken ToastConfig]: StaticInjectorError(Platform: core)[InjectionToken ToastConfig]:
Once I import:
import { ToastrModule } from 'ngx-toastr';
ToastrModule.forRoot({
timeOut: 5000,
positionClass: 'toast-bottom-center',
preventDuplicates: true,
closeButton: true,
progressBar: true,
maxOpened: 1,
autoDismiss: true,
enableHtml: true
}),
then that is fine. As I am planning to use in the future. Do I need to import it?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:10 (4 by maintainers)
Top GitHub Comments
yes the import will only work in
app.module
and not in any lazy loaded modules.@sonusindhu Are you importing it in the App Module?
@scttcper I have observed that when I import the module in any lazy loaded module I am getting the same error that @sonusindhu has mentioned. Importing it in the app module works fine.
Does the import work only in AppModule?