TheUnreal
TheUnreal

Reputation: 24472

Router errors after upgrading to Angular 2 RC

app/main-menu.component.ts(18,24): error TS2339: Property 'isRouteActive' does not exist on type 'Router'.
app/main-menu.component.ts(18,50): error TS2339: Property 'generate' does not exist on type 'Router'.

My main-menu component:

import {ROUTER_DIRECTIVES, Router} from '@angular/router';

...
directives: [ROUTER_DIRECTIVES],

export class MainMenuComponent {    

        constructor(private router: Router, private JwtService:JwtService){}

public isRouteActive(route) {
    return this.router.isRouteActive(this.router.generate(route))
}

}

I checked the angular 2 router docs and everything is still same, so why do I get this errors?

Upvotes: 1

Views: 1660

Answers (1)

Günter Zöchbauer
Günter Zöchbauer

Reputation: 657721

You are using the new router with the "old" code.

Change

import {ROUTER_DIRECTIVES, Router} from '@angular/router';

to

import {ROUTER_DIRECTIVES, Router} from '@angular/router-deprecated';

See also Angular2 router-deprecated dependencies not being loaded

Upvotes: 2

Related Questions