I am building an internal library for our projects, using Angular 6+.
I am using the .forRoot()
approach to register global services as documented.
My library will be using ngx-toastr
to provide notifications. As I don't want each project to deal directly with all the options of ngx-toastr
, I am abstracting most of it behind a notifications
service.
The way ngx-toastr
works, you can set global options by passing those global options to ToastrModule.forRoot()
.
how can I configure ToastrModule
as part of my own forRoot()
?
It's clearly a bad idea to add any code inside the .forRoot()
, but is the right way to initialize it directly in my @NgModule()
? like this:
@NgModule({
imports: [ToastrModule.forRoot(/* options go here? */)],
declarations: [],
exports: []
})
export class ToolsCoreModule {
static forRoot(): ModuleWithProviders {
return {
ngModule: ToolsCoreModule,
providers: [],
};
}
}
How would this interact if someone on the team decides to also call ToastrModule.forRoot()
within their own module initialization?