Skip to content

Instantly share code, notes, and snippets.

@rajaramtt
Created September 10, 2019 12:03
Show Gist options
  • Save rajaramtt/9c507e87f6b82105f1cb4a3caa0f622f to your computer and use it in GitHub Desktop.
Save rajaramtt/9c507e87f6b82105f1cb4a3caa0f622f to your computer and use it in GitHub Desktop.
public onlineOffline: boolean = navigator.onLine;
constructor(.......)
................
................
ngOnInit() {
window.addEventListener('online', () => {
this.onlineOffline = true;
});
window.addEventListener('offline', () => {
this.onlineOffline = false;
});
}
...............
...............
<mat-card *ngIf="!onlineOffline" class="internet-error">
No Internet connection. Please connect to the Internet and try again.
</mat-card>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment