title: In angular, how to use cancel an $interval on user events, like page change?
body: <p><a href="http://docs.angularjs.org/api/ng.$interval" rel="noreferrer">Angular documentation</a> about <code>$interval</code> is saying : </p>
  
  <blockquote>
    <p>Note: Intervals created by this service must be explicitly destroyed when you are finished with them. </p>
  </blockquote>
  
  <p>but it's not explaining how to destroy the $interval. </p>
  
  <p>If for example I have a directive containing this code : </p>
  
  <pre><code>$interval(function() {
      for (var i in myArray) {
          // do domething
      }
  }, 5000);
  </code></pre>
  
  <p>How can i destroy it when the user changes the page for example? </p>