Consider the following snippet. How do I access the provided value of Environment
in forRoot
? Is there an alternate way that I do the same?
interface Environment {
tokens: Record<string, string>;
}
const ENVIRONMENT = new InjectionToken<Environment>('ENVIRONMENT');
// `SomeModule` with `forRoot` to configure it. This module is from an external library.
// Some library module that I'm creating
@NgModule({
imports: SomeModule.forRoot() // `tokens` needs to passed here.
})
export class MyLibraryModule {}
MyLibraryModule
will be consumed in some application where ENVIRONMENT
will be injected. It will be lazily loaded