此代码在使用提前编译的开发模式下失败。
export function loggerFactory(console, http, device, injector) {
return environment.production ?
new LogstashLoggerService(device, injector, http) :
new ConsoleLoggerService(console);
};
let consoleObj = window.console;
@NgModule({
imports: [],
exports: [],
declarations: [],
providers: [],
})
export class LoggerModule {
static forRoot(): ModuleWithProviders {
return {
ngModule: LoggerModule,
providers: [
{provide: CONSOLE, useValue: consoleObj},
{
provide: Logger,
useFactory: loggerFactory,
deps: [CONSOLE, HttpInterceptor, DeviceService, Injector]
}
]
};
}
}
如何注入控制台?