Enabling the Service Worker
Now that the dependency is installed, it's time to enable the service worker.
This involves three steps:
Enabling the service worker in our browser app in
.angular-cli.json.Importing and registering the
ServiceWorkerModulein ourAppModule.Creating the service worker configuration file
src/ngsw-config.json.
We will use the ng set command to enable support for the service worker in our browser app in .angular-cli.json:
Open the terminal in the project directory.
Run the following command to adjust
.angular-cli.json:ng set apps.0.serviceWorker=true
Confirm that the property
serviceWorkeris set totruein the first app in theappsarray in.angular-cli.json:
Importing the ServiceWorkerModule
We will import the ServiceWorkerModule in our AppModule and register it.
We will invoke the register method on the ServiceWorkerModule. This method takes two parameters. The first parameter defines what the location of the Angular service worker is. The value '/ngsw-worker.js' is what...