0

I am finally learning Angular, but I ran into a problem. I am trying to create a warning component, but I am getting the following console error:

Unexpected value 'WarningComponent' declared by the module 'AppModule'. Please add a @Pipe/@Directive/@Component annotation.

Here is my main app.component.html code:

<div class="container">
  <div class="row">
    <div class="col-xs-12">
        <app-warning></app-warning>
    </div>
  </div>
</div>

Here is my app.module.ts code:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';

import { AppComponent } from './app.component';
import { ServerComponent } from './server/server.component';
import { ServersComponent } from './servers/servers.component';
import { WarningComponent } from './warning/warning.component';

@NgModule({
  declarations: [
  AppComponent,
  ServerComponent,
  ServersComponent,
  WarningComponent
],
imports: [
  BrowserModule,
  FormsModule,
  HttpModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }

Here is the actual warning.component.ts code:

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

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

export class WarningComponent {

}

Finally, here is the warning.component.html code (which is just some a warning text):

<h3>Warning</h3>

The page should simply output the text "Warning", but I am unsuccessful.

1 Answer 1

2

You need to remove the semicolon that's after @Component({}) in your warning.component.ts

Sign up to request clarification or add additional context in comments.

1 Comment

Wow. I must have forgotten this was angular and typescript, not jquery. Thank you. That solved my problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.