user4018959
user4018959

Reputation:

Angular 2 Error while routing to another component

I am using angular 2 beta 17 but error occurs.when I am Trying to Route to another Component. Kindly guide me. I will be very thankful to you.

enter image description here

 import {Component} from 'angular2/core';
import {Http, HTTP_PROVIDERS} from 'angular2/http';
import {MvcComponent} from "./components/mvc.component";
import {Location} from 'angular2/platform/common';
import {Router, RouteDefinition, RouteConfig, ROUTER_DIRECTIVES} from "angular2/router";
@Component({
    selector: 'my-app',
    templateUrl: './appScripts/layout/sidebar.html',
    directives: [ROUTER_DIRECTIVES]
})

@RouteConfig([
    {
        path: '/index',
        name: 'Index',
        component: MvcComponent,
        useAsDefault: true
    }
])


export class AppComponent {
    Profileimageurl: string = './images/flat-avatar.png';
    public routes: RouteDefinition[] = null;
    constructor(private router: Router,
        private location: Location) {

    }

    getLinkStyle(route: RouteDefinition) {
        return this.location.path().indexOf(route.path) > -1;
    }
}

Upvotes: 1

Views: 110

Answers (1)

Thierry Templier
Thierry Templier

Reputation: 202138

I think that you forgot to include the following file in your main HTML file:

<script src="node_modules/angular2/bundles/router.dev.js"></script>

Upvotes: 1

Related Questions