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.

Getting error: StaticInjectorError(Platform: core)[InjectionToken ToastConfig] in angular 8

See original GitHub issue

Hi 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:open
  • Created 4 years ago
  • Reactions:1
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

9reactions
ng-modelcommented, Apr 23, 2020

yes the import will only work in app.module and not in any lazy loaded modules.

8reactions
shayaneumar-mitelcommented, Nov 6, 2019

@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?

Read more comments on GitHub >

github_iconTop Results From Across the Web

NullInjectorError: StaticInjectorError(DynamicTestModule) ...
When i run the unit testing in angular 8 ...
Read more >
StaticInjectorError(Platform
Getting error : StaticInjectorError(Platform: core)[InjectionToken ToastConfig] in angular 8.
Read more >
NullInjectorError: No provider for InjectionToken ToastConfig!
angular #angulartutorial #angularproject #errorUncaught (in promise): NullInjectorError: No provider for InjectionToken ToastConfig !
Read more >
r3injectorerror(appmodule)[toastrservice -> injectiontoken ...
Angular - Jasmine // Error: NullInjectorError: R3InjectorError(DynamicTestModule)[AdminTestCentersComponent -> ToastrService -> InjectionToken ToastConfig ...
Read more >
Testing Notifications with Jasmine
Error : StaticInjectorError(DynamicTestModule)[ToastrService -> InjectionToken ToastConfig]: StaticInjectorError(Platform: core)[ToastrService ...
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