JSPM

network-status-angular

1.0.4
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 33
    • Score
      100M100P100Q62159F
    • License MIT

    Service for angular 6 to detect if the browser has network connection

    Package Exports

    • network-status-angular

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (network-status-angular) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    Service for angular 6 to detect if the browser has network connection.

    #Instalation

    npm install network-status-angular

    In app.module.ts

    import { NgModule } from '@angular/core';
    import { BrowserModule } from '@angular/platform-browser';
    import { AppComponent } from './app.component';
    import { NetworkStatusAngularModule } from 'network-status-angular';
     
    @NgModule({
      imports: [
        BrowserModule,
        // add NetworkStatusAngularModule in imports
        NetworkStatusAngularModule.forRoot()
      ],
      declarations: [AppComponent],
      bootstrap: [AppComponent]
    })
    export class AppModule {}

    Usage

    In order to use NetworkStatusService, it's necessary to init in one of your component, for example in app.component.ts.

    import { Component } from '@angular/core';
        import { NetworkStatusAngularService } from 'network-status-angular';
        
        @Component({
          selector: 'app-root',
          templateUrl: './app.component.html',
          styleUrls: ['./app.component.css']
        })
        export class AppComponent {
          constructor(private networkStatusAngularService: NetworkStatusAngularService) {
            this.networkStatusAngularService.status.subscribe(status => {
              console.log(status); // returns true if it is online or false if it is offline
            });
          }
        }