Detecting internet connection status in Angular application — ng-connection-service
It is a common requirement to detect internet connection status in running Angular application. We might want to show a message — “you are offline”, we might want to load cached data or we would user to take to “offline” page (route). Also as soon as internet connection is restored, we would like to make application functional without any user interaction.
We can achieve desired feature using
I have published an Angular service package —
npm repository which can be installed in Angular application.
You can install service via
npm i ng-connection-service
Here is the npm package library.
ConnectionServicein Angular component's constructor.
- Subscribe to
monitor()method to get push notification whenever internet connection status is changed.
ng-connection-service - Detects active internet connection in Angular application via DI ready Observable service.