TS1146:预期宣言..为什么?

时间:2017-11-06 16:53:12

标签: angular components angular-components

我有一个小问题。

我可能因为我累了,抱歉,我找不到解决办法。 有人可以帮帮我吗?

我有这个文件: src / app / app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { NgClass } from '@angular/common';
import { AppComponent } from './app.component';
import { ServerComponent } from './server/server.component';
@NgModule({
    declarations: [
        AppComponent,
        ServerComponent
    ],
    imports: [
        BrowserModule
    ],
    providers: [],
    bootstrap: [AppComponent]
})
export class AppModule { }

在这个组件内部,我创建了一个新组件,当然是样本。

的src /应用程序/服务器/ server.component.ts

import { Component } from '@angular/core';
@Component({
 selector: 'app-server',
 templateUrl: ''
});
export class ServerComponent {
};

的src /应用程序/服务器/ serve.component.html

<p>
 Start simple
</p>

超级简单吧?我同意。 但是当我尝试运行时,我收到了这个错误:

  

70%建筑模块3/3模块0活动ERROR in   src / app / server / server.component.ts(6,3):错误TS1146:声明   预期

系统找不到文件(server.component.ts),但我确实在这里正确放置了路径( src / app / app.module.ts ),我做了声明,我做了导入{Component}来自&#39; @ angular / core&#39 ;; 那么......缺少什么?我不明白。

谢谢大家。

2 个答案:

答案 0 :(得分:3)

你不应该在出口前加分号

import { Component } from '@angular/core';
@Component({
 selector: 'app-server',
 templateUrl: ''
 })
 export class ServerComponent {
 };

答案 1 :(得分:0)

有时多余的花括号会引发此类错误。 角度

相关问题