未捕获(承诺):模板解析错误:无法绑定到'routerLink',因为它不是已知的本机属性

时间:2016-05-09 13:32:58

标签: typescript angular

路由到另一个组件时发生以下错误。这是我的代码,我正在使用angular 2 beta 17.我已经在索引页面添加了所有必需的脚本。请帮助我。我将非常感谢你。

import {Component} from 'angular2/core';
import {MvcComponent} from "./components/mvc.component";
import {Location} from 'angular2/platform/common';
import {Router, RouteDefinition, RouteConfig, ROUTER_DIRECTIVES} from "angular2/router";
import {ChartComponent} from "./components/chart.component";
import {ChartsComponent} from "./components/charts.component";
import {Bootsrtap2Component} from "./components/bootstrap2.component";

import {BootstrapJavascriptComponent} from "./components/bootstrapjavascript.component";


@Component({
    selector: 'my-app',
    templateUrl: './appScripts/layout/sidebar.html',
    directives: [ROUTER_DIRECTIVES]
})

    @RouteConfig([

        {
            path: '/chart',
            name: 'Chart',
            component: ChartComponent
        },
        {
            path: '/charts',
            name: 'Charts',
            component: ChartsComponent
        },
        {
            path: '/index',
            name: 'Index',
            component: MvcComponent,
            useAsDefault: true
        },
        {
            path: '/components',
            name: 'Components',
            component: Bootsrtap2Component
        },
        {
            path: '/javascipt',
            name: 'Javascipt',
            component: BootstrapJavascriptComponent
        }
    ])

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;
    }
}

错误图像

enter image description here

0 个答案:

没有答案