angular/packages/examples/service-worker/registration-options/module.ts
Matthieu Riegler 09df589e31 refactor(core): Migrate all packages with the explicit-standalone-flag schematic. (#58160)
All components, directives and pipes will now use standalone as default.
Non-standalone decorators have now `standalone: false`.

PR Close #58160
2024-10-14 14:58:57 +00:00

42 lines
1.3 KiB
TypeScript

/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
// tslint:disable: no-duplicate-imports
import {Component} from '@angular/core';
// #docregion registration-options
import {NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {ServiceWorkerModule, SwRegistrationOptions} from '@angular/service-worker';
// #enddocregion registration-options
import {SwUpdate} from '@angular/service-worker';
// tslint:enable: no-duplicate-imports
@Component({
selector: 'example-app',
template: 'SW enabled: {{ swu.isEnabled }}',
standalone: false,
})
export class AppComponent {
constructor(readonly swu: SwUpdate) {}
}
// #docregion registration-options
@NgModule({
// #enddocregion registration-options
bootstrap: [AppComponent],
declarations: [AppComponent],
// #docregion registration-options
imports: [BrowserModule, ServiceWorkerModule.register('ngsw-worker.js')],
providers: [
{
provide: SwRegistrationOptions,
useFactory: () => ({enabled: location.search.includes('sw=true')}),
},
],
})
export class AppModule {}
// #enddocregion registration-options