Angular TS1146:需要声明。。为什么?

Angular TS1146:需要声明。。为什么?,angular,components,angular-components,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.com

我有个小问题

我可能是因为我累了,对不起,我找不到解决办法。 有人能帮我吗

我有这个文件: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 { }
import { Component } from '@angular/core';
@Component({
 selector: 'app-server',
 templateUrl: ''
});
export class ServerComponent {
};
在这个组件的内部,我创建了一个新组件,当然作为示例

src/app/server/server.component.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 { }
import { Component } from '@angular/core';
@Component({
 selector: 'app-server',
 templateUrl: ''
});
export class ServerComponent {
};
src/app/server/service.component.html

<p>
 Start simple
</p>

从简单开始

超级简单,对吧?我同意。 但当我尝试运行时,会出现以下错误:

70%构建模块3/3模块0中存在活动错误 src/app/server/server.component.ts(6,3):错误TS1146:声明 预料之中

系统找不到文件(server.component.ts),但我确实将路径正确地放在了这里(src/app/app.module.ts),我做了声明,我从'@angular/core'导入了{component} 所以少了什么?我不明白


谢谢大家。

导出前不应该放分号

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

有时额外的花括号会引发这样的错误。
角度

不要在标题中添加“已解决”。将问题标记为已解决的正确方法是提供答案并接受它。