Open ajazhmd opened 5 years ago
there isn't a way to import toastr from a shared module right now.
I'm facing the same issue. No current workaround?
@RoRoche I had to include ToastrModule.forRoot() in the imports of app module, it worked for me.
@ajazhmd here is the code I use:
@NgModule({
declarations: [AppComponent],
imports: [
...
ToastrModule.forRoot()
],
})
export class AppModule {}
@NgModule({
imports: [
...
ToastrModule
],
declarations: [OneSharedComponent, AnotherSharedComponent]
})
export class OneSharedModule {
}
@NgModule({
imports: [
...
ToastrModule
],
declarations: [SecondSharedComponent, StillAnotherSharedComponent]
})
export class SecondSharedModule {
}
I run using the following command:
ng serve core-app --prod
But when I go to the screen, I'm still facing this error:
ERROR Error: Uncaught (in promise): NullInjectorError: StaticInjectorError(AppModule)[OneSharedComponent -> ToastrService]:
StaticInjectorError(Platform: core)[OneSharedComponent -> ToastrService]:
NullInjectorError: No provider for ToastrService!
Am I missing something? Is my configuration wrong?
P.S. : what is weird is when I run ng serve core-app
(i.e., without the --prod
flag), all works fine.
P.S. : please excuse me for asking stupid questions, I'm not used to Angular 8 development and started few weeks ago on an existing project based on Nx.
@RoRoche try importing ToastrModule.forRoot() instead ToastrModule in your shared modules.
I am using ngx-toastr in one of my angular 7 library project, it is been consumed by another host project. The host project works perfectly fine in dev version, but when i create production build(using ng build --prod) it gives me following error: