Tuesday, December 7, 2021
Angular 13

Angular 13 Check Internet Connection Working Functionality

Angular 13 Check Internet Connection Working Functionality

Hello to all, welcome to In this post, I will tell you, Angular 13 Check Internet Connection Working Functionality.

Working Demo
Angular 13 Check Internet Connection Working Functionality
Angular 13 Check Internet Connection Working Functionality

Angular12 came and if you are new then you must check below two links:

  1. Angular13 Tutorials
  2. Angular Free Templates

Guys if you want to update your Angular old version to Angular 13 then please click here.

Here is the code snippet and please use carefully:

1. Very first guys, here are common basics steps to add angular 13 application on your machine and also we must have latest nodejs version(14.17.0) installed for angular 13:

$ npm install -g @angular/cli

$ ng new angulardemo// Set Angular 13 Application on your pc

cd angulardemo// Go inside project folder

2. Now we will add below code into our angularfullcalendar/src/app/app.component.ts file:

import { Component } from '@angular/core';
import { Observable, Observer, fromEvent, merge } from 'rxjs';
import { map } from 'rxjs/operators';
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
export class AppComponent {
   //function to check the internet connection
   checkConnection:string = '';
   therichpost$() {
    return merge<boolean>(
      fromEvent(window, 'offline').pipe(map(() => false)),
      fromEvent(window, 'online').pipe(map(() => true)),
      new Observable((sub: Observer<boolean>) => {;

  this.therichpost$().subscribe(isOnline => this.checkinterent = isOnline);
  //checking internet connection
  if(this.checkinterent == true)
    //show success alert if internet is working
    this.checkConnection = 'Your internet is working';
   //show danger alert if net internet not working
   this.checkConnection = 'Your internet is not working';

3. Finally we will add below code into our angularfullcalendar/src/app/app.component.html file:

<h1>{{ checkConnection }}</h1>

Now we are done friends and please run ng serve command to check output in browser(locahost:4200). If you have any kind of query then please do comment below.

Note: Friends, I just tell the basic setup and things, you can change the code according to your requirements. For better understanding must watch video above.

I will appreciate that if you will tell your views for this post. Nothing matters if your views will be good or bad.



Ajay Malhotra
the authorAjay Malhotra
Hello to all. Welcome to Myself Ajay Malhotra and I am freelance full stack developer. I love coding. I know WordPress, Core php, Angularjs, Angular 2, Angular 6, Angular 7, Angular 8, Angular 9, Angular 10, Angular 11, Angular12, Angular 13, Bootstrap 5, Nodejs, Laravel, Codeigniter, Shopify, Squarespace, jQuery, Google Map Api, Vuejs, Reactjs, Big commerce etc.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.