title: How to trigger a Javascript event on url change
body: <p>Currently, I am dealing with an angular project, I need to trigger an event on routing change/URL change from one page to another page (as it is an angular project page wont be refreshed).</p>
  
  <p>I have tried with different scenarios in index.html page like below:</p>
  
  <pre><code>  window.onbeforeunload = function () {
     //not fit;
    });
  
      window.onhashchange = function () {
      //not fit;
     });
  </code></pre>
  
  <p>Can we have any other solutions to trigger an event on url change (I don't want to use listeners in angular).</p>