/
githubmirror
/
angular
Обзор
Документация
Войти
/
githubmirror
/
angular
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/examples/service-worker/registration-options/module.ts
42 строки
1 KB
Matthieu Riegler
refactor(core): Migrate all packages with the `explicit-standalone-flag` schematic. (#58160)
14 окт 2024, 17:58
14 окт 2024, 17:58
09df589
Код
Авторство
О чём код?
/** * @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