i am using ngx toastr in angular 8 its showing below error if anyone knowns the solution tell me

1k views Asked by At

ERROR Error: Uncaught (in promise): NullInjectorError: StaticInjectorError(AppModule)[ToastrService]: StaticInjectorError(Platform: core)[ToastrService]: NullInjectorError: No provider for ToastrService! NullInjectorError: StaticInjectorError(AppModule)[ToastrService]: StaticInjectorError(Platform: core)[ToastrService]: NullInjectorError: No provider for ToastrService! at NullInjector.get (core.js:855) at resolveToken (core.js:17514) at tryResolveToken (core.js:17440) at StaticInjector.get (core.js:17266) at resolveToken (core.js:17514) at tryResolveToken (core.js:17440) at StaticInjector.get (core.js:17266) at resolveNgModuleDep (core.js:30393) at NgModuleRef_.get (core.js:31578) at injectInjectorOnly (core.js:734) at resolvePromise (zone-evergreen.js:797) at resolvePromise (zone-evergreen.js:754) at zone-evergreen.js:858 at ZoneDelegate.invokeTask (zone-evergreen.js:391) at Object.onInvokeTask (core.js:39680) at ZoneDelegate.invokeTask (zone-evergreen.js:390) at Zone.runTask (zone-evergreen.js:168) at drainMicroTaskQueue (zone-evergreen.js:559) at ZoneTask.invokeTask [as invoke] (zone-evergreen.js:469) at invokeTask (zone-evergreen.js:1603)

2

There are 2 answers

1
andsilver On

Import ToastrModule in your AppModule:

import { ToastrModule } from 'ngx-toastr';

...

@NgModule({
    imports: [
        ...
        ToastrModule.forRoot({
          positionClass: 'toast-bottom-right',
          progressAnimation: 'decreasing',
          preventDuplicates: true,
          progressBar: true,
        })
    ]
})
export class AppModule {}
0
scttcper On

You are most likely using the wrong version of ngx-toastr for your version of angular. Check which version is compatible here https://github.com/scttcper/ngx-toastr#dependencies