title: How to detect network is disconnected in Angular 2+
body: <p>I try to find network disconnected issue. I have tried multiple ways. Still i didn't get the solution. I could not achieve with status code.</p>
  
  <p>Here is my sample code:</p>
  
  <pre><code>    var headers = new Headers();
      headers.append('Content-Type', 'application/json');
      headers.append('Authorization', 'Bearer ' + this.token); 
  
      this.http.get('http://someurl/'+userId,{headers:headers})
  
      .map(res =&gt; res.json())
  
      .subscribe(
        data =&gt; {
        console.log(data);
       },
  
      error =&gt; {
        console.log(error);
        if(error.status == 500) {
          this.dashResponse = false;
          this.notFoundResponse = false;
          this.serverErrorResponse = true;
        }
        else if(error.status == 404)
        {
          this.dashResponse = false;
          this.notFoundResponse = true;
          this.serverErrorResponse = false;
        }
        else if(error.status == 401)
        {
          this.router.navigate(['/login']);
          alert('Un Authorized');
          this.refresh();
        }
        else
        {
          this.dashResponse = false;
          this.notFoundResponse = false;
          this.serverErrorResponse = true;
        }
      }
  
       );
  </code></pre>
  
  <p>Can any one solve my problem ?. Thanks in Advance.</p>