Angular 2 setinterval() keep running on other component
<p>I have the following method in one component:</p>

<pre><code>ngOnInit()
        {
            this.battleInit();
            setInterval(() =&gt; {
                this.battleInit(); 
                }, 5000);
        }
</code></pre>

<p>Now, I need to run this interval only if the user is in this specific component, that means that when the user navigate away from this component the interval will stop.</p>

<p>Currently, <code>this.battleInit()</code> is executed every 5 seconds, even after the user navigates away from this page.</p>

<p>Short question: How do I stop <code>setInterval()</code> when user navigate away (by routing) to another component?</p>