Enabling offline mode with the service worker
Users from anywhere can now access our Angular application to get weather information for any city they are interested in. When we say anywhere, we mean any network type, such as broadband, cellular (3G/4G/5G), and Wi-Fi. Consider the case where a user is in a place with low coverage or frequent network outages. How is our application going to behave? Let’s find out by experimenting:
- Run the Angular application using the
ng serve
command of the Angular CLI. - Open your favorite browser and navigate to
http://localhost:4200
, the default address and port number for an Angular CLI project. You should see the input field for entering the name of the city:
Figure 4.3 – Entering the name of a city
- Open the developer tools of your browser and navigate to the Network tab. Set the value of the Throttling dropdown to Offline:
Figure 4.4 – Offline network mode
- Try...