Angular ServiceWorkerModule.register与动态URL
我正在尝试注册AngularAngular ServiceWorkerModule.register与动态URL,angular,typescript,service-worker,angular-service-worker,Angular,Typescript,Service Worker,Angular Service Worker,我正在尝试注册AngularServiceWorkerModule,并动态地将URL传递给工作者脚本。在myapp.module.ts中: import { ServiceWorkerModule } from '@angular/service-worker'; @NgModule({ // … imports: [ // our setup requires to set this dynamically ServiceWorkerModule.register(`
ServiceWorkerModule
,并动态地将URL传递给工作者脚本。在myapp.module.ts
中:
import { ServiceWorkerModule } from '@angular/service-worker';
@NgModule({
// …
imports: [
// our setup requires to set this dynamically
ServiceWorkerModule.register(`${window.baseUrl}/ngsw-worker.js`)
]
});
export class AppModule {}
不幸的是,AOT编译器对变量进行了“优化”,最终得到了一个字符串null/ngsw worker.js
我怎样才能防止这种情况