service-worker-registration.ts
angular/examples/week11-12/service-worker-registration.ts
// @ts-nocheck
export function registerServiceWorker(): void {
if (typeof window === 'undefined' || !('serviceWorker' in navigator)) {
return;
}
window.addEventListener('load', () => {
navigator.serviceWorker
.register('/ngsw-worker.js')
.then((registration) => {
console.info('Service worker registered:', registration.scope);
})
.catch((error) => {
console.error('Service worker registration failed:', error);
});
});
}
Articles liés
server.js
server.js — javascript source code from the angular learning materials (angular/comprehensive-demo/server/server.js).
Lire l'article →app.component.ts
app.component.ts — typescript source code from the angular learning materials (angular/comprehensive-demo/src/app/app.component.ts).
Lire l'article →app.config.ts
app.config.ts — typescript source code from the angular learning materials (angular/comprehensive-demo/src/app/app.config.ts).
Lire l'article →app.routes.ts
app.routes.ts — typescript source code from the angular learning materials (angular/comprehensive-demo/src/app/app.routes.ts).
Lire l'article →auth.guard.ts
auth.guard.ts — typescript source code from the angular learning materials (angular/comprehensive-demo/src/app/core/guards/auth.guard.ts).
Lire l'article →role.guard.ts
role.guard.ts — typescript source code from the angular learning materials (angular/comprehensive-demo/src/app/core/guards/role.guard.ts).
Lire l'article →