0

考虑以下代码段。如何访问Environmentin提供的值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将被注入的应用程序中消耗。它将被延迟加载

4

0 回答 0