anchal.gaur
anchal.gaur

Reputation: 11

I have imported app component in app.module.ts file but still is not working

'app-header' is not a known element:

  1. If 'app-header' is an Angular component, then verify that it is part of this module.
  2. If 'app-header' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("wrapper"> [ERROR ->]

Upvotes: 0

Views: 5004

Answers (4)

supreethapavan
supreethapavan

Reputation: 21

I had the same error:I am new to ang2 I had a mismatch b/w selector name and the tag name in app.component.ts

@Component({ selector: 'app-my-home',

}) in my my-home.component.ts and i was trying <'my-home'>in app.component.ts. As i changed to <'app-my-home'> , it worked

Upvotes: 0

sn42
sn42

Reputation: 2444

Did you declare your component in the module? For example:

@NgModule({
  declarations: [
    AppComponent,
    LoginComponent,
    DashboardComponent,
    VideosComponent
  ],
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
    SharedModule,
    CoreModule,
    AppRoutingModule,
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Note this sample doesn't use your app-header component.

Upvotes: 0

Anavar Bharmal
Anavar Bharmal

Reputation: 329

There should be many reasons for this error. You can check below point to solve this error.

1) check the selector name declared in component and used name 2) app-header component must be declared in some module in declarations 3) If there is some another module for app-header, then import that module in your current module 4) restart the server after each change (may be in some case)

Upvotes: 0

Hasan Fathi
Hasan Fathi

Reputation: 6086

this error related to angular-cli you have 'app-header' component and use it, but this component not a part of any module in your application. for fix this error define this component in your app.module.ts file like this:

add your component class name in declarations section

@NgModule({
  declarations: [
    AppComponent,
    AppHeader
  ],
  imports: [
    BrowserModule,
    BrowserAnimationsModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Upvotes: 2

Related Questions