Skip to content
Permalink
Browse files

register serviceworker in app.module and main.ts

  • Loading branch information...
ademidun committed Sep 13, 2018
1 parent 5ed539c commit d2b186f1ecc3a0862fcb3bd863643f1d28eac970
Showing with 13 additions and 0 deletions.
  1. +2 −0 src/app/app.module.ts
  2. +11 −0 src/main.ts
@@ -34,6 +34,7 @@ import {SearchService} from './_services/search.service';
import {ScholarshipService} from './_services/scholarship.service';
import {TeamComponent} from './team/team.component';
import { NotFoundComponent } from './not-found/not-found.component';
import {ServiceWorkerModule} from '@angular/service-worker';

@NgModule({
declarations: [
@@ -47,6 +48,7 @@ import { NotFoundComponent } from './not-found/not-found.component';
imports: [
SharedModule,
NgbModule.forRoot(),
ServiceWorkerModule.register('/ngsw-worker.js', {enabled: environment.production}),
BrowserModule,
AppRoutingModule,
MatDialogModule,
@@ -11,3 +11,14 @@ if (environment.production) {
platformBrowserDynamic().bootstrapModule(AppModule)
.catch(err => console.log(err));

if ('serviceWorker' in navigator && environment.production) {
console.log("Service Worker in main.ts");
window.addEventListener('load', () => {
console.log("on page Load Service Worker in main.ts");
navigator.serviceWorker.register('/ngsw-worker.js', {
scope: '/',
})
.then(registration => {
console.log("Service Worker registration completed main.ts", registration);
});
});

0 comments on commit d2b186f

Please sign in to comment.
You can’t perform that action at this time.