Angular 2: TypeError: Cannot read property 'isRouteActive' of undefined in
<p>I am trying to use <code>isRouteActive</code> function to switch the <code>active</code> class of the <code>li</code> elements upon clicking the links contained within them, but it keeps giving me the errors like <code>TypeError: Cannot read property 'isRouteActive' of undefined in [isRouteActive(['./Home']) in AppComponent@6:16]</code>. The file looks like the following:</p>

<pre><code>import {Component} from 'angular2/core';
import {ROUTER_DIRECTIVES, RouteConfig, Router } from 'angular2/router';
import {FORM_PROVIDERS, FORM_DIRECTIVES, Control} from 'angular2/common';
import {LoginComponent} from './login.component.js';
import {HomeComponent} from './home.component.js';

@Component({
selector: 'front-page-app',
providers: [ FORM_PROVIDERS ],
directives: [ ROUTER_DIRECTIVES, FORM_DIRECTIVES ],
template: `
&lt;div class="container"&gt;
  &lt;div class="header clearfix"&gt;
    &lt;nav&gt;
      &lt;ul class="nav nav-pills pull-right"&gt;
        &lt;li #homeLink role="presentation" 
            [class.active]="isRouteActive(['./Home'])"&gt;
        &lt;a [routerLink]="['./Home']"&gt;Home&lt;/a&gt;
        &lt;/li&gt;
        &lt;li #loginLink role="presentation" 
            [class.active]="isRouteActive(['./Login'])"&gt;
        &lt;a [routerLink]="['./Login']"&gt;Login&lt;/a&gt;
        &lt;/li&gt;
      &lt;/ul&gt;
    &lt;/nav&gt;
    &lt;h3 class="text-muted"&gt;Fomoapp&lt;/h3&gt;
  &lt;/div&gt;
&lt;/div&gt; &lt;!-- /container --&gt;
&lt;router-outlet&gt;&lt;/router-outlet&gt;
`
})

@RouteConfig([
{ path: '/login', component: LoginComponent, name: 'Login' },
{ path: '/home', component: HomeComponent, name: 'Home' },
{ path: '/', redirectTo: ['Home'] }
])
export class AppComponent { 
public isRouteActive(route) {
    return this.router.isRouteActive(this.router.generate(route))
}
}
</code></pre>

<p>I tried a variety of paths, like '/home', '#/home', '/Home', './Home', 'Home' but none of them work. What the error could be related to? And how to actually debug such situations? </p>