0
このコードは、Ahead of time compilationで開発モードで失敗します。AOT付きAngular 4インジェクションコンソール
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]
}
]
};
}
}
コンソールを挿入するにはどうすればよいですか?
(の可能性のある重複[アンギュラ4 IBMアカデミーとuseValueプロバイダとして使用される場合、ウィンドウが定義されていません] https://stackoverflow.com/questions/43445947/window-is-undefined-when-used-as-usevalue-プロバイダー付き4角形) – estus