Typescript 编译器错误预期带有 Angular 1.5 组件的分号

Posted

技术标签:

【中文标题】Typescript 编译器错误预期带有 Angular 1.5 组件的分号【英文标题】:Typescript compiler error expected semi-colon with Angular 1.5 component 【发布时间】:2016-09-11 23:05:44 【问题描述】:

在尝试编译以下 Angular 组件时,我收到来自 TypeScript 的预期分号错误。

这对我来说似乎很好,但只有在我添加 this.$routeConfig 数组时才抛出错误:

export class AppComponent implements ng.IComponentOptions 
    public template: string;
    public $routeConfig: Array<any>;
    constructor()
        this.template = `<h1>Home</h1>
                        <ng-outlet></ng-outlet>`;
        this.$routeConfig: [ 
            path: '/', 
            component: 'loginComponent', 
            name: 'Login', 
            useAsDefault: true
        ];
    

【问题讨论】:

【参考方案1】:

刚刚意识到我的“小学生”错误!

应该是this.$routeConfig = [];

【讨论】:

以上是关于Typescript 编译器错误预期带有 Angular 1.5 组件的分号的主要内容,如果未能解决你的问题,请参考以下文章