title: Equivalent of jQuery ajaxStart in Angular 2
body: <p>I want to know if there is an equivalent of ajaxStart or ajaxStop in Angular 2.</p>
  
  <p>I want to check if there's an ajax which runs into the document.</p>
  
  <p>According the <strong><a href="http://api.jquery.com/ajaxStart/" rel="nofollow">official documentation</a></strong> of ajaxStart, it will be triggered when there is any Ajax Request. And I want something like this in Angular 2.</p>
  
  <pre><code>$( document ).ajaxStart(function() {
    $( "#loading" ).show();
  });
  </code></pre>
  
  <p>I do this:</p>
  
  <ul>
  <li>into my <code>app.component.ts</code>, I show my loader</li>
  <li>when my ajax is success, I hide my loader</li>
  </ul>
  
  <p>But, some of my page doesn't have ajax call, so if I show my loader using my <code>app.component.ts</code>, it will be impossible to hide this, because, none of ajax request is present into this page.</p>
  
  <p>I think, if I listen if ajax is not present into my page, if will hide my loader.</p>
  
  <p>I use <code>localStorage</code> to save the status of ajax.
  If the page has ajax, I set a value to that xhr
  Otherwise, I remove the status stored into <code>localStorage</code>.
  Each time, the user arrive in the page. My script check, if there is an ajax running into that page.</p>
  
  <p><strong>app.component.ts</strong></p>
  
  <pre><code>if(localStorage.getITem("xhr")) {
      // action here
  }
  </code></pre>
  
  <p><strong>request.service.ts</strong></p>
  
  <pre><code>...
  let checkForAjax: any = {
      setXhr () {
          localStorage.setItem("xhr", "1");
      },
      removeXhr () {
          localStorage.removeItem("xhr");
      }
  }
  ...
  </code></pre>
  
  <p>into get request, I do this (before success callback):</p>
  
  <pre><code>checkForAjax.setXhr()
  </code></pre>
  
  <p>And into callback of get request, I just remove the status.</p>
  
  <pre><code>checkForAjax.removeXhr()
  </code></pre>
  
  <p>By the way, I haven't the <code>xhr</code> status, after my ajax is successed. So If I check it into my <code>app.component.ts</code>, I just test if there's a property <code>xhr</code>into my <code>localStorage</code>.</p>
  
  <p>I work now, but I want another way to listen for ajax with angular 2.</p>
  
  <p>Is that way exist?
  How can it will be done?</p>