考虑以下代码段。如何访问Environment
in提供的值forRoot
?有没有另一种方法可以让我做同样的事情?
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
将在某些ENVIRONMENT
将被注入的应用程序中消耗。它将被延迟加载