Get active link in Angular 2
<p>I am attempting to get the active link in Angular 2 so I can update my css in my template.</p>

<p>This is what I have done with the help of google:</p>

<pre><code>export class AppComponent {
    router: Router;

    constructor(data: Router) {
        this.router = data;
    }

    isActive(tab): boolean {
        if (this.router.currentInstruction &amp;&amp; this.router.currentInstruction.component.routeData) {
            return tab == this.router.currentInstruction.component.routeData.data['activeTab'];
        }
        return false;
    }
}
</code></pre>

<p><strong>My template is as follows:</strong></p>

<pre><code>  &lt;li class="some-class" [ngClass]="{active: isActive('some-route')}"&gt;

                &lt;a [routerLink]="['SomeRoute']" class="menu-item" &gt;&lt;span&gt;Link1&lt;/span&gt;&lt;/a&gt;

            &lt;/li&gt;
</code></pre>

<p>While this works, I note the <a href="https://angular.io/docs/ts/latest/api/router/RouterLink-directive.html" rel="nofollow">RouterLink directive</a> has the method: isRouteActive.</p>

<p>This would seem like a sensible way to manipulate the link class using this.</p>

<p><strong>But how do I use it?</strong></p>