Angular 角度分量意外值

Angular 角度分量意外值,angular,typescript,Angular,Typescript,我终于学会了,但我遇到了一个问题。我试图创建一个警告组件,但出现以下控制台错误: Unexpected value 'WarningComponent' declared by the module 'AppModule'. Please add a @Pipe/@Directive/@Component annotation. 以下是我的主要app.component.html代码: <div class="container"> <div class="row">

我终于学会了,但我遇到了一个问题。我试图创建一个警告组件,但出现以下控制台错误:

Unexpected value 'WarningComponent' declared by the module 'AppModule'. Please add a @Pipe/@Directive/@Component annotation.
以下是我的主要app.component.html代码:

<div class="container">
  <div class="row">
    <div class="col-xs-12">
        <app-warning></app-warning>
    </div>
  </div>
</div>
以下是实际的warning.component.ts代码:

import { Component } from '@angular/core';

@Component({
selector: 'app-warning',
templateUrl: './warning.component.html'
});

export class WarningComponent {

}
最后,这里是warning.component.html代码(只是一些警告文本):

警告

该页面应该只输出文本“Warning”,但我没有成功。

您需要删除
@Component({})
Warning.Component.ts
@Component({})
之后的分号。您需要删除
Warning.Component.ts
哇。我一定忘了这是angular和typescript,不是jquery。非常感谢。这解决了我的问题。我一定忘了这是angular和typescript,不是jquery。非常感谢。这解决了我的问题。
import { Component } from '@angular/core';

@Component({
selector: 'app-warning',
templateUrl: './warning.component.html'
});

export class WarningComponent {

}
<h3>Warning</h3>